I'm having an issue making a Web API call from an angular/hottowel app where the Web API controller is using attribute-based routing. I'm currently wondering if angular is interfering but, honestly, I have no idea how to confirm.
My service method looks like this:
function getAllOrganizations() {
return $http.get('api/organizations').then(function (result) {
return result.data;
});
}
It's returning a 404 when it's called:
GET http://localhost/admin/api/organizations 404 (Not Found)
I should mention at this point that the app is hosted in a virtual directory 'admin'. Checking my routes with routes.axd, it looks ok to me (Methods = GET, HEAD, OPTIONS, Url = api/organizations etc.), matching my method/attribute (I have tried this both with and without a leading '/' with no effect):
[GET("/api/organizations")]
[HttpGet]
public string GetAllOrganizations()
{
return "it worked";
}
Any ideas what is going on? What other information would be useful?
UPDATE
Switching back to IIS Express caused an eeor along the lines of:
"The constraint entry 'inboundHttpMethod' on the route with route template 'api/Contacts/{id}' must have a string value or be of a type which implements 'IHttpRouteConstraint'
Having fixed that with help from here, running this in IIS Express works.
(And, in a subsequent test, moving the app to be it's own website also makes it start working...)
So it seems there is an issue, maybe, with attribute-based routing in a virtual directory - does that ring a bell?