Copied to clipboard

Flag this post as spam?

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

  • Nathan Woulfe 375 posts 1417 karma points MVP 2x c-trib
    Feb 07, 2017 @ 08:01
    Nathan Woulfe

    Trying to set up a simple WebApi endpoint, using a custom route (ie not ~/umbraco/api/foo/bar) - figured it would be a matter of adding the WebApiConfig class, invoking it, and then using route attributes in my controller, inheriting from ApiController.

    I figured wrong - I get 404s on all routes. Wondering if there's any other Umbraco logic I need to be aware of, or if I'm just missing something obvious.

    I know code samples would help, but I'm at home and the code is at work...

  • Matt Brailsford 2300 posts 11175 karma points MVP 6x c-trib
    Feb 07, 2017 @ 11:01
    Matt Brailsford

    Hey Nathan,

    Have you read through the Api Controller docs, it goes into pretty good detail as to how they should be setup in Umbraco

    Hope this helps


  • Nathan Woulfe 375 posts 1417 karma points MVP 2x c-trib
    Feb 07, 2017 @ 11:17
    Nathan Woulfe

    Thanks Matt, read through that earlier. Should I be able to define my own routes against a controller inheriting from UmbracoApiController? It's not critical, but I'd prefer to define my own via attributes...

  • Aaron 21 posts 92 karma points
    Apr 05, 2017 @ 17:34

    Had a similar problem getting web api working after umbraco was installed in a project.

    This blog post solved the problem for me, it appears you need to register your custom web api routing after umbraco has started and registered its routes.

  • bronzewind 35 posts 118 karma points
    Aug 22, 2019 @ 15:44

    Hi everyone I was able to make this work but unfortunately this page is formatting it incorrectly so these are my pics of how I made it work in Umbraco V8:

    1. Created a composer: enter image description here

    2. Created a custom controller inheriting from UmbracoApiController: enter image description here

      1. Call it like GET http://[website_url]/frontend/api/customdata/{param1}/{param2}/
  • Sandra26 15 posts 115 karma points
    Oct 09, 2019 @ 13:00

    Hi bronzewind,

    I tried your solution. It was very easy to implement. But I'm getting 404 response. Any idea what can be the issue?

    Hope to hear from you, Sandra26

  • bronzewind 35 posts 118 karma points
    Oct 09, 2019 @ 13:26

    Hi Sandra,

    404 means the endpoint is not being found. please be sure you are calling the api with all the parameters, that you're inheriting from UmbracoApiController and the Composer matches the one in the example.

    If you don't find where the issue is, feel free of pasting here your code or more details about your implementation so that I can give it a look.


Please Sign in or register to post replies

Write your reply to: