0

In my angular service , i am sending data to API controller as follow.

The only problem here is StudentIds, value does not pass to the web API controller. But i am able to get values for Date and Status. Only issue is with StudentIds as i am sending an array of StudentIds.

How i can resolve this issue?

$rootScope.$broadcast('download', _apiUrl + 'GetStudentReport', { date: date, status: status, StudentIds: StudentIds });

API Controller:

[HttpGet]
[Route("GetStudentReport")]
public HttpResponseMessage GetStudentReport(DateTime date, bool status, [FromUri] Guid[] StudentIds )
{

}
simbada
  • 940
  • 4
  • 24
  • 43
  • Please provide full code . Controllers hierarchy etc. – Ashot Nov 27 '15 at 11:55
  • controllers hierarchy?? Which hierarchy? – simbada Nov 27 '15 at 11:56
  • angular controller hierarchy in your html – Ashot Nov 27 '15 at 11:59
  • you are broadcasting an event 'download' but where you catch it in your code ? – Ashot Nov 27 '15 at 12:00
  • `$rootScope.$broadcast` should has an handler function somewhere such as `$rootScope.$on('download',function{// handle event here})` – Ashot Nov 27 '15 at 12:01
  • in download the uri constructed like this.https://localhost:12340/api/Reports/GetStudentReport?date=2015-11-12&localClientTime=2015-11-27 16:03:23&status=false&StudentIds=e0f54905-b091-e511-830c-303a64efb676,def54905-b091-e511-830c-303a64efb676 – simbada Nov 27 '15 at 12:09

1 Answers1

0

Arrays are a special case with MVC , you have to pass it in a specific way for the controller to recreate it from the URL .

Take a look at this .

https://stackoverflow.com/a/9508310/2794980

You will have to write a custom model binder if your url is not in this format.

SomeActionName/?StudentIds=1&StudentIds=2

Community
  • 1
  • 1
Pratik
  • 868
  • 1
  • 9
  • 24