Reputation: 5851
I am trying to call post api on button click but I shows this error:
Supplied parameters do not match any signature of call target
Code:
changeStatus(id) {
this.http.post('https://localhost:44300/api/apis/ChangeStatus/' + id)
.subscribe(
data => this._data = data.json(),
err => this.logError(err)
);
}
Upvotes: 16
Views: 38079
Reputation: 752
post
method requires at least two parameters, first 'URL', and second 'Body' and in your code you are just passing URL not body.
Upvotes: 1
Reputation: 23506
http.post
expects a body to be sent to the target host.
http.post(url, body, requestOptions)
So if you just want an empty body, because you have no additional data to send, you could do this:
changeStatus(id) {
// mind the empty string here as a second parameter
this.http.post('https://localhost:44300/api/apis/ChangeStatus/' + id, "")
.subscribe(
data => this._data = data.json(),
err => this.logError(err)
);
}
Upvotes: 23