You have to JSON.stringify the object before you send it in the payload:
return Restangular.all('records/StartNewDate').post(JSON.stringify(departments));
Pregunta
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; }
}
Solución
You have to JSON.stringify the object before you send it in the payload:
return Restangular.all('records/StartNewDate').post(JSON.stringify(departments));