Copied to clipboard

Flag this post as spam?

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


  • Chris Perks 32 posts 114 karma points
    Mar 24, 2014 @ 23:02
    Chris Perks
    0

    Default Get method for UmbracoApiController

    In vanilla Web Api, I can have something like:

        // GET api/products
        [HttpGet]
        public IEnumerable<Product> Get()
        {
            return Products.GetAll();
        }

    I am creating a controller (implementing UmbracoApiController) in v7 and would like to have a default action method for Get() requests on that controlller.

    This doesn't seem to work, I have to call /api/products/get to get anything back from the controller. 

    Are default Get methods supported in Umbraco?

     

    Thanks.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Mar 25, 2014 @ 06:53
    Jeroen Breuer
    0

    Hello,

    I tried myself, but it looks like that won't work and you need to go to the full url.

    Here are some more examples: http://our.umbraco.org/projects/developer-tools/hybrid-framework/hybrid-framework/47815-Using-Ajax-with-the-framework?p=0#comment172879

    Jeroen

  • Chris Perks 32 posts 114 karma points
    Mar 27, 2014 @ 12:55
    Chris Perks
    0

    Thanks for the tips, Jeroen!

    I'm going to have a play with some custom routing at the weekend and see what I can come up with.

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Mar 27, 2014 @ 15:11
    Dave Woestenborghs
    1

    In the original post you mention that you try to acces your API with the following url :  /api/products/get

    This should be : /umbraco/api/products/get

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft