Copied to clipboard

Flag this post as spam?

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


  • Martin McCarthy 2 posts 72 karma points
    Mar 15, 2021 @ 12:05
    Martin McCarthy
    0

    UmbracoApiController returning 404 error

    Hi All,

    I'm trying to build a super basic api in umbraco v8.11.1. I've followed the documentation here https://our.umbraco.com/documentation/Reference/Routing/WebApi/

    using System.Web.Http;
    using Umbraco.Web.WebApi;
    
    namespace ContentPlatform.MyWelfare.Controllers
    {
        public class ContentController : UmbracoApiController
        {
            [HttpGet]
            public string GetContent()
            {
                return "This worked!";
            }
        }
    }
    

    When testing in postman im pointing at the following endpoint

    http://localhost:51397/umbraco/api/content/getcontent
    

    However no matter what i try i'm getting a 404 not found error.

    Can anyone give me some advice or guidance on this please?

  • Huw Reddick 1932 posts 6722 karma points MVP 2x c-trib
    Mar 15, 2021 @ 15:12
    Huw Reddick
    1

    just a thought but maybe it doesn't like your controller being called content.

  • Martin McCarthy 2 posts 72 karma points
    Mar 16, 2021 @ 08:46
    Martin McCarthy
    0

    Hi Huw,

    I thought the same but I renamed it TestController and still had the same issue.

  • Brendan Rice 538 posts 1102 karma points
    Mar 16, 2021 @ 10:38
    Brendan Rice
    0

    How is your project set up (web app or web site)?

    Where does the controller sit in the solution (which folder)?

  • Huw Reddick 1932 posts 6722 karma points MVP 2x c-trib
    Mar 16, 2021 @ 17:58
    Huw Reddick
    0

    can't think of anything off hand, your code looks fine and should work.

  • Brendan Rice 538 posts 1102 karma points
    Mar 16, 2021 @ 20:10
    Brendan Rice
    0

    The only thing I can think of is that it's a website project and the code isn't getting compiled.

    If it's a website there should be an App_Code folder that houses this class.

  • Amalie Wowern 145 posts 274 karma points MVP c-trib
    Jun 02, 2022 @ 14:17
    Amalie Wowern
    0

    Did you find a solution?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

    Continue discussion

Please Sign in or register to post replies