2016-07-12 14 views
16

sto provando a chiamare posta api sul tasto di scatto ma mi mostra questo errore:angolare 2 Errore parametri forniti non corrispondono ogni firma del target chiamata

Supplied parameters do not match any signature of call target

Codice:

changeStatus(id) { 
    this.http.post('https://localhost:44300/api/apis/ChangeStatus/' + id) 
     .subscribe(
      data => this._data = data.json(), 
      err => this.logError(err) 
     ); 
} 
+0

Su quale riga si verifica l'errore? – rinukkusu

+0

secondo codice di riga 'this.http.post ('https: // localhost: 44300/api/apis/ChangeStatus /' + id)' –

risposta

22

http.post aspetta un corpo da inviare all'host di destinazione.

http.post(url, body, requestOptions) 

Quindi, se si desidera solo un corpo vuoto, perché non si hanno dati aggiuntivi per inviare, si potrebbe fare questo:

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) 
     ); 
} 
+0

Gran problema risolto (Y) –

1

post metodo richiede almeno due parametri, prima 'URL', e secondo 'Corpo' e nel tuo codice stai passando l'URL non il corpo.

Problemi correlati