Search code examples
javascriptasp.net-web-api2breeze

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:

  • SQL Server Express v2012
  • Breeze on the server side is v1.5.0.0
  • Entity Framework v6
  • Microsoft.Data.OData is v5.6

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.


Solution

  • 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);