in ASP.NET Web Api

Passing arrays into a ASP.NET Web Api method as parameters

Here is an easy way to pass in a array of values as parameters in a ASP.NET Web Api method.

1
2
3
4
5
6
        [HttpGet()]
        public HttpResponseMessage FindByMembers([FromUri]Int32[] ids = null)
        {
           //Do stuff
            return Request.CreateResponseMessage(HttpStatusCode.OK);
        }

The Url will be http://mywebsite/api/mycontroller/findbymembers/?ids=1&ids=2&ids=3.

Happy API coding!