Pagination Documentation

Is there no way to paginate with just page size and page number?

On reading the documentation it appears that to paginate I need to know either the last document id from the previous page or the first document id from the next page.

This is really difficult to use as you cannot go to page 6 unless you have been to page 5 or page 7. Please tell me I have missed something.

Here is my powershell example to paginate through users:

$uri = “https://[tenant]”



$webrequest = Invoke-WebRequest -TimeoutSec 300 -Headers @{“Authorization” = $apiKey} -Method Get -Uri $uri

$link = $webrequest.Headers.Link.Split("<").Split(">")

$uri = $link[3]

$json = $webrequest | ConvertFrom-Json

$allusers += $json

} while ($webrequest.Headers.Link.EndsWith(‘rel=“next”’))

$activeUsers = allusers | Where-Object { _.status -ne “DEPROVISIONED” }

$activeUsers | Sort-Object lastLogin | Select profile, lastLogin | Export-Csv -Path C:\Users.csv -NoTypeInformation