I do not know because when I do a post by angular, objects are not populated, such as categories or status. Just the product. However, note that the Request.Form list, the information is there. The binder is not performed correctly. What am I doing wrong? Is it any web api configuration? I've tried sending data via application/json, [frombody] ... I'm out of options. Thanks in advance.
var product = {
id: 1,
name: "Name",
categories: [
{ id: 1, name: "name 1" },
{ id: 2, name: "name 2" }
],
status: { id: 1, name: "active" }
};
var config: ng.IRequestConfig;
config = { url: "", method: "POST", headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;' } };
self.$http.post("api/produto", $.param(product), config)
.success(function () {
alert("OK");
});
[HttpPost]
public ProductInfo Post(ProductInfo item)
{
return item;
}
try this: