I am trying to retrieve all eligible assignments from the following endpoint:
https://graph.microsoft.com/v1.0/roleManagement/directory/roleEligibilitySchedules
This also means I need to paginate over all pages and this is an issue because I can not figure out how to do it.
Normally, response would contain @odata.nextLink
, which is not the case on this api. I tried to limit the page size with top
the following way, which correctly returned 2 records, but no next page link:
https://graph.microsoft.com/v1.0/roleManagement/directory/roleEligibilitySchedules?$top=2
I tested this on https://developer.microsoft.com/en-us/graph/graph-explorer.
Initially, I granted permissions to my registered app. Then I navigated to Graph Explorer and modified the permissions, granting admin consent. After that I tried using the endpoint you tried but I didn’t receive the @odata.nextLink in the response
https://graph.microsoft.com/v1.0/roleManagement/directory/roleEligibilitySchedules
Next I tried applying $top=2 in the endpoint as you did. I received 2 results, but I didn’t receive the @odata.nextLink in the response.
https://graph.microsoft.com/v1.0/roleManagement/directory/roleEligibilitySchedules?$top=2
After that, I checked my eligible roles count, which is 50, but @odata.nextLink is still not showing in the response.
I added two more eligible PIM roles, and I observed that @odata.nextLink appeared in the response. It seems that whenever the number of eligible roles exceeds 50, @odata.nextLink is included. The screenshot below shows the response for your reference
Output: