由于departments
是null
,此消息已发布到服务器
JavaScrtipt代码:
var departments = [{ DepartmentName : "Name", DepartmentId : 1}];
Restangular.all('records/StartNewDate').post(departments);
Web Api控制器
public HttpResponseMessage StartNewDate(DepartmentViewModel[] departments)
{
....
....
}
服务器型号
public class DepartmentViewModel
{
public int DepartmentId { get; set; }
public string DepartmentName { get; set; }
}
最佳答案
您必须先将JSON.stringify对象发送到有效负载中:
return Restangular.all('records/StartNewDate').post(JSON.stringify(departments));