yesiamaguest yesiamaguest - 4 months ago 17x
AngularJS Question

How can I send a response from Web API to an angular resource query?

I have the following Angular query.

services.factory('UserFactory', function ($resource) {
return $resource('/api/users', {

}, {
query: { method: 'GET' }


$scope.searchedUsers = UserFactory.query({ searchString: "test" });

From Asp.Net Web Api, I'm returning

return Request.CreateResponse<List<User>>(HttpStatusCode.OK, users);

Then Angular throws the error

Response does not match configured parameter Error in resource
configuration for action
. Expected response to contain an
array but got an {2} (Request: {3} {4})

But when I look at the response in developer tools, it appears to be an array:


Why is it throwing this error?


Set your factory to

query: { method: 'GET',isArray:true}