此帖子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; }
}
答案 0 :(得分:5)
在将对象发送到有效负载之前,您必须对该对象进行JSON.stringify:
return Restangular.all('records/StartNewDate').post(JSON.stringify(departments));