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 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( int[] employeeIds)
{
    return Ok();
}
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Reply


x

Interesting BlogPosts to read

Introduction to Dataset API Meetup
Bangalore Apache Spark Meetup is hosting an event on Introduction to Dataset API on February 13 , 20...
Webinar - Best Practices - Optimizing ASP.NET Performance, Part 1
DevExpress is hosting a webinar on the topic "Best Practices - Optimizing ASP.NET Performance, Part ...
How to Serialize Enum to String in ASP.NET ?
Sometimes when developing an web application , the developers might want to serialize Enum to its st...