odata datajs batch paging

1k Views Asked by At

In the example below how/where do I specify $skip and $top parameters?

OData.request( {
    requestUri: "http://ODataServer/FavoriteMovies.svc/$batch",
    method: "POST",
    data: { __batchRequests: [
       { requestUri: "BestMovies(0)", method: "GET" },
       { requestUri: "BestMovies(1)", method: "GET" }
    ]}
},
function (data, response) {
    //success handler
}, undefined, OData.batchHandler);
1

There are 1 best solutions below

0
On

The batch URL itself does not take skip/top parameters because it doesn't deal with a server collection of entities, instead it just refers to a collection of operations.

You can add the $top/$skip values inside the requestUri instead, but it won't work for the examples given because refer to single entities - you can tell because the parens indicate they refer to their key.

Instead you can do somethingn like BestMovies?$top=10 in the requestUri, and the first response in the batch will contain those first ten movies.