Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ross Ekberg 130 posts 381 karma points
    May 17, 2022 @ 19:06
    Ross Ekberg
    0

    Auto Routing Not Working

    I am attempting to create an API. I have saved this file in the App_Code folder:

    namespace My.Controllers
    {
    
        [Umbraco.Web.Mvc.PluginController("My")]
        public class SubscriptionPickerAPIController : UmbracoAuthorizedJsonController
        {
            public string GetAll()
            {
                <Code Code Code>
            }
        }
    }
    

    However, when I attempt to visit https://domain.com/umbraco/backoffice/My/subscriptionpickerapi/getall, I get a 404 error. Why? I ahve a test environment and it works just fine.

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    May 17, 2022 @ 21:15
    Paul Seal
    0

    Hi Ross

    An UmbracoAuthorizedJsonController needs to be called from the Umbraco backoffice. You won’t be able to visit the url itself in the browser. If you just want your own api controller that is public you can use UmbracoApiController

    Paul

  • Ross Ekberg 130 posts 381 karma points
    May 18, 2022 @ 13:31
    Ross Ekberg
    0

    Thanks for the response. I do want the api to be called from the back office. That is where it is to be used.

    The only reason I mention visiting the URL is because it was a clear example to me that it isn't working. In my test environment, the routing works as expected and, if I attempt to visit the URL as mentioned above, I get an error generated by Umbraco, saying something to the effect of "GET requests aren't supported", or something like that. However, when I try to visit the URL in my live environment, I get a browser-issued 404 error.

    In the back office, when I use the api, in my test environment, they work correctly. But in my live environment, Umbraco just tells me it can't be found.

    So I guess my question is, is there something special I need to do to get the auto-routing to work or to happen?

  • Ross Ekberg 130 posts 381 karma points
    May 18, 2022 @ 22:41
    Ross Ekberg
    0

    For some rason, I am no longer getting a direct 404 error when I visit the URL https://domain.com/umbraco/backoffice/My/subscriptionpickerapi/getall. Now, I instead get the following error:

    No HTTP resource was found that matches the request URI

    So it seems Umbraco is now responding. So that's good. How would I go about fixing this?

Please Sign in or register to post replies

Write your reply to:

Draft