PRB
PRB

Reputation: 1041

WebAPI using BreezeJS throws an error as soon as I use $skip

I have a working WebAPI (v2) which utilizes the awesome BreezeJS product. I am attempting to add paging capabilities, but as soon as I include $skip in the URL as a parameter, the WebAPI generates this error:

{
  $id: "1",
  $type: "System.Web.Http.HttpError, System.Web.Http",
  Message: "An error has occurred."
}

Debugging the API does not give me any additional information, since it doesn't crash.

The parameters I'm passing are: http://www.example.com/api/Test/Designs?$skip=5&$top=5&$inlinecount=allpages&

If I call it without the $skip parameter, it works fine. The other "$" params seem to work just fine, as I can call:

http://www.example.com/api/Test/Designs?$top=3

and it works as expected.

I have verified that I'm not using any BreezeQueryable attributes or anything, so $skip should be allowed.

Additional setup info if it helps:

Is there something else I need to have enabled in order to utilize paging? Or is there a way I can find the true cause of this error? I can provide a working URL if requested.

Thank you.

Upvotes: 1

Views: 112

Answers (1)

Jeremy Danyow
Jeremy Danyow

Reputation: 26396

A sort is required to use skip:

From the breeze docs:

// Skip the first 10 Products and return the rest
// Note that the  '.orderBy' clause is necessary to use '.skip'
// This is required by many server-side data service implementations
var query3 = EntityQuery.from('Products')
    .orderBy('ProductName')
    .skip(10);

Upvotes: 1

Related Questions