locked
How to pass an array of values in ASP.NET Web API url RRS feed

  • Question

  • User732011909 posted

    hi all ,

    i want to pass an array of values instead of id in ASP.NET Web API url

    please provide soultion regarding this

    Thanks

    Saturday, October 28, 2017 5:52 AM

Answers

  • User-474980206 posted

    if its a get, the standard approach for an array is a common parameter name in the query string

       ?id=1&id=2&id=3

    though another common (python) is to include the array index ([idx]):

       ?id%5B0%5D=1&id%5B1%5D=2&id%5B2%5D=3

    either will work with webapi.

       public MyClass get ([FromUri] int[] id) {...}

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, October 28, 2017 7:44 PM