Posting an array to web.api (api controller) does not work in it's most simple form I guess.
I have this JavaScript
var ann = { Age: 11, Name: 'Ann' };
var bob = { Age: 22, Name: 'Bob' };
var list = [ann, bob];
$.ajax({
url: '/api/myapi/',
data:list,
dataType: 'json',
type: "POST",
});
And then I have a web.api with a simple post handler
public void Post(JObject pList)
{
//Whatever
}
If I change "data:list" with "data:ann" then everything works as expected (except bob doesn't come over of course). But the minute I put a list then it doesn't work.
I have tried to look up solutions, and some seem to serialize manually in JavaScript, is that the correct "solution"/"best practice" to this issue, or is there an easier way?