Copied to clipboard

Flag this post as spam?

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


  • liran 59 posts 140 karma points
    Mar 14, 2018 @ 05:54
    liran
    0

    hi i added REST API, the Get() method working only if the Get(int id) not existing.

    how can i make it to work as a regular REST service when the GET without parameters automatically give all data and when i add an id it will go to the other method?

    public class RestServiceController : UmbracoApiController
    {
        // GET: Umbraco/api/RestService
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }
    
        // GET: api/RestService/5
        public string Get(int id)
        {
            return "value: " + id;
        }
    

    }

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Mar 14, 2018 @ 10:15
    Dave Woestenborghs
    100

    Hi liran,

    If i'm correct you will need to use /umbraco/api/RestService/Get/5 or /umbraco/api/RestService/Get?id=5

    Dave

  • liran 59 posts 140 karma points
    Mar 15, 2018 @ 11:07
    liran
    0

    10x

Please Sign in or register to post replies

Write your reply to:

Draft