How to pagination of access request pending approval

We need to bring all the access requests that are in pending for approval, we are able to fetch first 250 and we are trying to paginate but we are ended up going to infinite loop
API used : list-pending-approvals | SailPoint Developer Community
To implement this we are trying to create powershell script

This is how we are doing it via powershell script

# Get Total Count Access Requests

$response = Invoke-WebRequest 'https://sailpoint.api.identitynow.com/v3/access-request-approvals/pending?count=true' -Method 'GET' -Headers @{"Accept"="application/json"; "Content-Type"="application/json"; "Authorization"="Bearer $token"}
$count = $response.headers.'X-Total-Count'

# Get All Access Requests 

$offset = 0
while ($offset -lt $count){
$response = Invoke-RestMethod "https://saiilpoint.api.identitynow.com/v3access-request-approvals/pending?offset=$offset" -Method 'GET' -Headers @{"Accept"="application/json"; "Authorization"="Bearer $token"}
$requests += $response
$offset = $offset + 250
}
3 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.