Unable to paginate more than 1000 records when getting user roles

Overview

When calling out the Management API endpoint /api/v2/roles/{id}/users in order to paginate over all the users assigned to a role an error is returned after requesting a certain number of pages.

 

Symptoms
The response to the request returns a 400 status code and contains the following error message:

Requesting page 10 exceeds the allowed maximum of 1000 records. To fetch results beyond 1000, use the checkpoint pagination method.

Applies To
  • API endpoint /api/v2/roles/{id}/users
Cause
The request to the endpoint is using offset pagination (page and per_page parameters); this type of pagination is limited to returning only 1000 records. This means that requesting page N will throw an error if the following condition is true:
N * RPP + RPP > 1000
where N is the page index being requested and RPP is the number of records per page being requested. For example, when requesting 100 records per page the error will be thrown when page index is the value 10.

Have in mind that the above logic is independent of the actual number of records (users) associated to the role; even if the role has less than 1000 users associated with it the endpoint will report an error if an attempt is made to request a page index that would go over the maximum based on the number of per page records being requested.
 
Solution
In order to call this endpoint and paginate over more than 1000 records the checkpoint pagination (from and take parameters) approach must be used as documented at (https://auth0.com/docs/api/management/v2#!/Roles/get_role_user).

Recommended content

No recommended content found...