I call http post method from angular4 component to web api. When I print those values return from web api on console it prints empty values. I checked the request using postman also. It also didn't work.
Http post call from component file.
EditValue(event, name, id) {
const headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' });
const options = new RequestOptions({ headers: headers });
let body = { "name" : name, "id": id }
this.http_.post('http://localhost:12412/api/employee?', body, options)
.subscribe((data) => {console.log(data)});
}
Http post method in web api.
[HttpPost]
public string postemp(Model model)
{
return "name:" +model.name + " , " + "id: " + model.id;
}
public class Model
{
public int id { get; set; }
public string name { get; set; }
}
When I check the name and id from Editvalue function those values are passing. I tried solutions given by Angular4 http post method does not pass data to web api also. But issue didn't fix.How to check those posted data is passing to web api post method?
I attached the response result I got below.
