WebAPI routing does not work
WebAPI routing does not work
I have WebApiConfig
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
Web API controller:
[RoutePrefix("api/Trip")]
public class TripApiController : ApiController
{
[Route("SaveRouting")]
[HttpPost]
public async Task<HttpResponseMessage> SaveRouting(string points, int tripId, decimal totalMileage)
{
// ......
return Request.CreateResponse(HttpStatusCode.OK);
}
and call from jquery:
$.post("/api/trip/SaveRouting",
{ points: JSON.stringify(arrayStops), tripId: $("#hdTripId").val(), totalMileage: tMiles },
function(resp) {
App.unblockUI(blockElRouting);
});
it tries to call, but failure:
App Insights says:
what is invalid?
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.