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 370 posts 1385 karma points MVP 2x c-trib
    Feb 07, 2017 @ 08:01
    Nathan Woulfe
    0

    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 2274 posts 11082 karma points MVP 6x c-trib
    Feb 07, 2017 @ 11:01
    Matt Brailsford
    0

    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

    https://our.umbraco.org/documentation/reference/routing/webapi/

    Hope this helps

    Matt

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

    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
    Aaron
    1

    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.

    http://www.andreasjohansson.eu/technical-blog/configuring-custom-web-api-routing-for-umbraco-sites/

  • bronzewind 32 posts 113 karma points
    Aug 22, 2019 @ 15:44
    bronzewind
    1

    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
    6 days ago
    Sandra26
    0

    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 32 posts 113 karma points
    6 days ago
    bronzewind
    0

    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.

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft