Malik Kashmiri
Malik Kashmiri

Reputation: 5851

Angular 2 Error Supplied parameters do not match any signature of call target

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

Answers (2)

Ravinder Kumar
Ravinder Kumar

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

Maximilian Riegler
Maximilian Riegler

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

Related Questions