How do you add a custom route for UmbracoAuthorizedApiController?
Hi
I'm trying to call/post to a UmbracoAuthorizedApiController from a custom backend control with the following signature.
public HttpResponseMessage VariantOptionsAreAvailable(int productId, int variantId, int[][] options) {
....
return new HttpResponseMessage(HttpStatusCode.OK);
}
When called I get a 404. I can't figure out how to create a custom route ... I get RouteTable does not exist in current context from custom ApplicationEventHandler class.
Using Umbraco 7.12.4
Never used WebApi so am obviously getting this wrong ... whats the best way to approach posting some data to a UmbracoAuthorizedApiController?
That's a good point, I think I was assuming it must need a custom route as I just can't get it to call the api. UmbracoAuthorizedApiController works fine on other simpler methods.
If I change it to a surfaceController rather than a UmbracoAuthorizedApiController it just works perfectly (as below).
[HttpPost]
public bool VariantOptionsAreAvailable(int productId, int variantId, int[][] options)
{
return ....
}
How do you add a custom route for UmbracoAuthorizedApiController?
Hi
I'm trying to call/post to a UmbracoAuthorizedApiController from a custom backend control with the following signature.
public HttpResponseMessage VariantOptionsAreAvailable(int productId, int variantId, int[][] options) { .... return new HttpResponseMessage(HttpStatusCode.OK); }
When called I get a 404. I can't figure out how to create a custom route ... I get RouteTable does not exist in current context from custom ApplicationEventHandler class.
Using Umbraco 7.12.4
Never used WebApi so am obviously getting this wrong ... whats the best way to approach posting some data to a UmbracoAuthorizedApiController?
Any thoughts much appreciated - thank you.
Do you need to create a custom route? API controllers are automatically routed for you. See https://our.umbraco.com/documentation/Reference/Routing/Authorized/
That's a good point, I think I was assuming it must need a custom route as I just can't get it to call the api. UmbracoAuthorizedApiController works fine on other simpler methods.
If I change it to a surfaceController rather than a UmbracoAuthorizedApiController it just works perfectly (as below).
So are you calling it using the following route:
If I were you'd I'd try calling it without any parameters by both GET and then POST to determine if that works. Maybe help you narrow down the issue.
is working on a reply...