I want my edit-views to retrieve data from an ApiController so I followed the tutorial here.
I get a 404-error, when I try to get the data from the Api controller.
It seems that there has been som changes to the routing paths in the 7.0.2 (read article here)
The article states: "It is good practice to never hard code any URLs based on both WebAPI or MVC controllers because routes can change. The UrlHelper for both WebAPI and MVC should be used instead to generate the URL for a particular route."
Well, the tutorial hard codes the URL's which is where I'm stuck. I've tried the fix mentioned in the article but to no avail. The article also mentions a "UrlHelper", which seems could be handy for this kinda problem; I can't find any documentation on how to use this, though.
Also: Where is the URL to the Api Controller documentet? I kinda pattern-matched the URL from the tutorial to my own application but I'm not really sure it's right.
Hi. I've previously had a v7.0 api controller working but have been concentrating on the front-end since upgrading to 7.02; today I revisited to find it had stopped working and found your comment here about the breaking change. I guess I should actually read release notes once in a while! :)
I too was suffering from a 404 on the backoffice API controller and I found that the details in the "breaking change" page you link to provides incorrect information. In my solution at least, instead of
/umbraco/backoffice/{controller}/{action}
it should be
/umbraco/backoffice/api/{controller}/{action}
I've also posted a comment on the referenced page.
Routing to ApiController in 7.0.2
I'm building an extension to the back-end.
I want my edit-views to retrieve data from an ApiController so I followed the tutorial here.
I get a 404-error, when I try to get the data from the Api controller.
It seems that there has been som changes to the routing paths in the 7.0.2 (read article here)
The article states: "It is good practice to never hard code any URLs based on both WebAPI or MVC controllers because routes can change. The UrlHelper for both WebAPI and MVC should be used instead to generate the URL for a particular route."
Well, the tutorial hard codes the URL's which is where I'm stuck. I've tried the fix mentioned in the article but to no avail. The article also mentions a "UrlHelper", which seems could be handy for this kinda problem; I can't find any documentation on how to use this, though.
Also: Where is the URL to the Api Controller documentet? I kinda pattern-matched the URL from the tutorial to my own application but I'm not really sure it's right.
Application-Name: "Races", Controller-name: "PersonApiController", Method: "GetById"
Url: "/Backoffice/Races/DistanceApi/GetById?id=[id]" - where [id] is some id route path.
Best regards
Frederik
Frederik,
Try and get your url like
string apiUrl = Url.GetUmbracoApiService
Also in OnApplicationStarting are you wiring up routes?
Hi Ismail
Thanks for the response :-)
The URL:
I think we are talking about different things (I admit that I was a little vague in my initial description)
I'm talking about reaching the ApiController from the resource.js-file (which in terms supplement the angular-controller with data).
I must admit that I'm fairly new to the angular-framework so please bear with me if I have misunderstood some concept.
The route wiring:
I was under the impression that the attribute "[PluginController("Races")]" did the wiring for me, since this wasn't described in the tutorial.
Thanks in advance
Frederik
Hi. I've previously had a v7.0 api controller working but have been concentrating on the front-end since upgrading to 7.02; today I revisited to find it had stopped working and found your comment here about the breaking change. I guess I should actually read release notes once in a while! :)
I too was suffering from a 404 on the backoffice API controller and I found that the details in the "breaking change" page you link to provides incorrect information. In my solution at least, instead of
it should be
I've also posted a comment on the referenced page.
I hope this helps.
Hi Kevin
Thank you for your response.
I have tried the following:
With area-name:
/umbraco/backoffice/api/Races/DistanceApi/GetById
Without area-name:
/umbraco/backoffice/api/DistanceApi/GetById
But it still doesn't seem to work. Any ideas?
- Frederik
is working on a reply...