NextPagingToken
NextPagingToken concept similar to Continuation token
for managing the results returned from queries.
Every query submitted to headless that returns a list will have an optional MaxItems
limit property. The default limit is 250.
If the result returned to the client has nextPagingToken
different from null
, means that the result is partial and more records are available on request (basically going from page to page until the nextPagingToken
is null
).
In order to go the next page, only thing you need to do is to supply your nextPagingToken
as a part of the request.
In case you want to go backwards you have to store the nextPagingToken
on your site and make requests with it.
Keep in mind that the nextPagingToken
is unique per store.
Note: The token can appear under 2 different names, "pagingToken" or "nextPagingToken".
Example when MaxItems
is set to 3:
curl -D- -X GET https://umbracodemo1.ucommerce.net/api/v1/countries?maxItems=3 \ -H 'Authorization: Bearer <ACCESS_TOKEN>' -H 'Content-Type: application/json' \
Response:
{ "countries": [ { "cultureCode": "da-DK", "id": "0c53f836-9601-ec11-837b-64bc58542c92", "name": "Denmark" }, { "cultureCode": "de-DE", "id": "1153f836-9601-ec11-837b-64bc58542c92", "name": "Germany" }, { "cultureCode": "en-GB", "id": "0f53f836-9601-ec11-837b-64bc58542c92", "name": "Great Britain" } ], "nextPagingToken": "M3wzfGRjMDZlZGYxLTQ2MGQtNGVlZC1hMzMxLWJjNWYwMzI4NDlkNHxGYWxzZQ==" }
To get the next 3 countries you do the following request:
curl -D- -X GET https://umbracodemo1.ucommerce.net/api/v1/countries?maxItems=3&nextPagingToken=M3wzfGRjMDZlZGYxLTQ2MGQtNGVlZC1hMzMxLWJjNWYwMzI4NDlkNHxGYWxzZQ== \ -H 'Authorization: Bearer <ACCESS_TOKEN>' -H 'Content-Type: application/json' \
Possible errors that may occur:
Error | Description |
---|---|
BadRequest (400) | Store not found on the given context; Paging token does not match the current query; etc. |
Example:
{ "errors": [ { "error-description": "Store not found on the given context", "error": "BadRequest" } ] }
See Handling failures for more info.