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; }
}
¿Fue útil?

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));
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top