Вопрос

Is it possible to pass a jagged array to a web API method? For example:

public IEnumerable<Object> Get([FromUri]int[][] jaggedArray)

How would I be able to to pass a value for jaggedArray in my web request? The parameter doesn't necessarily have to be [FromUri]

Это было полезно?

Решение

I managed to figure it out. The parameter can be passed using the following format:

http://www.example.com/api/endPoint?jaggedArray[0][]=406&jaggedArray[0][]=404&jaggedArray[1][]=405&jaggedArray[1][]=407

This causes a jagged array containing two arrays, each with two numbers (406 and 404 for the first, then 405 and 407 for the second,) to be received.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top