I tried to follow this example.
Here is my C# code:
public class MyModel
{
int? ID { get; set; }
}
public class MyResourceController : ApiController
{
[HttpPost]
public MyModel MyPostAction(MyModel model)
{
return model;
}
}
Here is my JavaScript:
var data = { model: { ID: 1 } };
$http.post(
'/api/MyResource/MyPostAction',
JSON.stringify(data),
{
headers: {
'Content-Type': 'application/json'
}
}
);
When I set a breakpoint in my action and model.ID
is null
instead of 1
. How can I POST a complex object?