I am encountering an issue where I am trying to invoke a simple method using TypeScript code as well as Chrome Advanced Rest Client, but I keep receiving a 404 error.
WebApi Method
[HttpPost]
[Route("api/offert/TestPost")]
public IHttpActionResult TestPost(int idid)
{
//http://localhost/prova/api/offert/TestPost
var anonymousTypeVar = new { x = 15, y = 120 };
return Json(anonymousTypeVar);
}
TypeScript Code
var data = { idid: 1};
this.baseUrl = 'http://localhost/prova/api/offert/';
this.http.post(this.baseUrl + "TestPost", JSON.stringify(data),
this.getRequestOptions)
.map(response => response.json())
.subscribe();
Despite my efforts, the 404 error persists...
I am aware that I could append "?idid=1" to the URL as a parameter, but my intention is to pass a Json string to the webmethod...
What changes should I make in the code?
Thank you