I have an object called "ReferenceNumber". Reference numbers have a "Number" and a "Type".
The javascript object looks like this:
{
"type" : ""
"number" : ""
}
I need to send a list of these "ReferenceNumber"s to a C# System.Web.Http.ApiController. My method looks like this:
[HttpGet]
[Route(@"")]
public HttpResponseMessage MyMethod([FromUri]List<ReferenceNumber> refNumbers)
{
...
}
I'm using $http from Angularjs to try to make all my API calls. I prefer to be able to do something like:
$http.get("MYURL", obj);
But I'm willing to use jQuery.param or JSON.stringify if need be. Or:
$http.get("MYURL", {params: {refNumbers: referenceNumbers}});
Or whatever. But no matter what combination of these things I try, including just hardcoding, I can't seem to get the list to be sent over. I can get a null list, an empty list, or a list with items in it with Number and Type properties that are null, but I can't get my data.
How can I send this data properly? Is sending a list simply not done? And, if so, why is a list not acceptable? Should I package my list in an object? Must I use [FromBody] instead of [FromUri] and force my data in there?