This get posted to the server as departments
are null
JavaScrtipt code:
var departments = [{ DepartmentName : "Name", DepartmentId : 1}];
Restangular.all('records/StartNewDate').post(departments);
Web Api Controller
public HttpResponseMessage StartNewDate(DepartmentViewModel[] departments)
{
....
....
}
Server Model
public class DepartmentViewModel
{
public int DepartmentId { get; set; }
public string DepartmentName { get; set; }
}
You have to JSON.stringify the object before you send it in the payload:
return Restangular.all('records/StartNewDate').post(JSON.stringify(departments));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With