Question

Collections return a maximum of 100 records per page, and by default return 100 records per page. How can I change this default value?

Was it helpful?

Solution

You can set this on a per request basis by passing e.g. per_page=50 in the request parameters. You iterate the collection by incrementing the page attribute, e.g. page=3. Collections also include links in the response body for easier navigation, generally they are on this structure:

{
  "users": [ ... ],
  "count": 1234,
  "next_page": "https://account.zendesk.com/api/v2/users.json?page=2&per_page=50",
  "previous_page": null
}

Stop paging when the next_page attribute is null.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top