So I am trying to pass a string to my Web Api through a put call in an Angular service. The service actually calls the method on the Web Api side, but the parameter always comes through null. Can someone shed a bit of light, thanks.
Here is what the code looks like:
Web Api: (the breakpoint is set on the first parenthesis)
public void Put([FromBody]string userId)
{
}
Angular :
UpdateManagerEmail(userId){
userId = '577f1e6e-146d-49f1-a354-b31349e7cb49';
const headers = new HttpHeaders();
headers.append('Content-Type', 'application/json');
this._http.put('http://localhost:428/api/User', {
userId : userId
}).subscribe(returnVal => {
console.log('returned');
});
}
this._http.put('http://localhost:428/api/User', '"' + userId + '"')OR setting a variablevar data = userIdand just passing data into the put method?this._http.put('http://localhost:428/api/User', data)