I'm using AngularJS $http to send data to my Web API server. I don't know why, but my JS Array is not going to the server side, it's going NULL, the id is going OK.
This is what I have:
Client-Side:
var dataArray = [
{
Prop1: "4674279"
}
];
var id = 1;
$http({
method : 'POST',
url : 'http://localhost/Services/Controller/Method',
auth : true,
data: {
'id' : id,
'items' : dataArray
},
headers: {
"Content-Type": "application/json"
}})
.success(function (data, status, headers, config) {
if (status === 200) {
return data;
}
})
.error(function (data, status, headers, config) {
console.log('[ERROR] Status Code:' + status);
});
Server-Side:
public partial class Item
{
public string Prop1 { get; set; }
}
public ReturnType Method(int id, List<Item> items)
{
}
What I'm doing wrong? I've tried JSON.stringify and so on, but wont works.