public class ProductApiController : UmbracoApiController
{
public IEnumerable<Product> GetAll(string homeId)
{
return ContentService.Instance.GetAllProducts(homeId);
}
}
works fine you you call it like
/Umbraco/Api/ProductApi/GetAll?homeId=1050
however if you call it like
/Umbraco/Api/ProductApi/GetAll/homeId/1050
or
/Umbraco/Api/ProductApi/GetAll/1050
You get error
"No HTTP resource was found that matches the request URI"
So is this way of calling webapi which works as I have done it before outside of umbraco not work with umbraco webapi?
WebApi routing
I have the following web api controller:
works fine you you call it like
however if you call it like
/Umbraco/Api/ProductApi/GetAll/homeId/1050
or
/Umbraco/Api/ProductApi/GetAll/1050
You get error
"No HTTP resource was found that matches the request URI"
So is this way of calling webapi which works as I have done it before outside of umbraco not work with umbraco webapi?
Regards
Ismail
Searching (http://our.umbraco.org/search?q=No%20HTTP%20resource%20was%20found%20that%20matches%20the%20request%20URI&content=forum,) gives the following topic with the same issue: http://our.umbraco.org/forum/developers/extending-umbraco/46086-UmbracoApiController-No-HTTP-resource-was-found-that-matches-the-request-URI
aha, makes sense that second post however at least you can map your own route then what ever you pass in will work.
Cheers
Ismail
If in your example you call it Id instead of homeId, it will work with the default root eg /umbraco/api/ProductApi/GetAll/1050
Marc,
No that is a bit dirty in that id does not reflect intent of the parameter. I have got it working so i did
and my url
Umbraco/Api/ProductApi/GetAll/1050
works.
Regards
Ismail
just illustrating why it wasn't working, ie homeid didn't match the current default route :-)
but yes now you have a special custom route that 'knows about' the specialness of the homeid parameter in your route.
Hey guys, just a question, can we have the route even more clean and "restfull"? Like this:
And call it like this?
Thanks! Joao.
is working on a reply...