Passing Array of Integers to ASP.NET Web API REST Service

You can pass an array of integer to an ASP.NET Web Web API REST service by setting the [FromUri] attribute for the parameter of the action method.

How to pass an array of integer to ASP.NET Web API REST Service?

Assume that you want to access the Employees with the id’s 1,2,3 and you would like to pass them in the parameter of the URL and retreive this as the array of integers in the action method. Here’s how your action method will look like.

public IHttpActionResult GetEmployees([FromUri] int[] employeeIds)
{
    return Ok();
}

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

One of the common ways to refresh webpage every few mins is by using JavaScript or HTML Meta tag. For...
This post will provide the list of some of the top ASP.NET based Content Management Systems (CMS) that you may...
Well i have been wandering around here and ther for quite a few days in understanding how to dynamically create...