I have been trying to call an API using $http.get method but its not calling that API instead just returning 404 error.
My $http
$http({
method: 'POST',
url: '/SalesManagement/SecuredSalesAPI/GetProductLine'
}).then(function(res) {
debugger
console.log(res.data);
}, function(header) {
debugger
console.log("HTTP Head: " + JSON.stringify(header));
});
//My route public class SalesManagementAreaRegistration : AreaRegistration { public override string AreaName { get { return "SalesManagement"; } } public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "SalesManagement_default",
"SalesManagement/{controller}/{action}/{id}", new { action = "Home", id = UrlParameter.Optional } ); } }
My API:
public class SecuredSalesAPI : Controller
{
public JsonResult GetProductLine()
{
var sp = entity.spGetProductPerformance(startDate, end, "HPL");
return Json(sp, JsonRequestBehavior.AllowGet);
}
}
// and the namespace is
// namespace WebApp.Areas.SalesManagement.Controllers
method: 'POST',|trying to call an API using $http.get<= Your code conflicts with your statement, which is it you are actually trying to do?