Hi,
Hoping that someone can point out what I am doing wrong with the following snippet. The code works, but observationally the API is doing the offset THEN sorting the results. This means that it brings back the same results occasionally. I’ve added code to fix that problem, but whilst I like fudge, I’d rather not have it in my code. How do I structure the API call so that it sorts the results before setting the offset - is that even possible?
# --- Step 2: Get all Identities and their Assigned Access (Roles and Access Profiles) ---
Write-Host "Fetching all Identities and their assigned Access..."
$identityQueryBody = @{
indices = @("identities")
query = @{
query = "attributes.cloudLifecycleState:active"
sort = @(
@{field = "id"; order = "asc" }
)
}
offset = 0
limit = 50
}
$identityQueryBody.offset = 0
while ($continueIdentities) {
try {
$identityResponse = Invoke-RestMethod -Uri "https://$tenant.api.identitynow.com/v3/search?offset=$($identityQueryBody.offset)&limit=$($identityQueryBody.limit)" -Method 'POST' -Headers $headers -Body ($identityQueryBody | ConvertTo-Json -Depth 10) -ErrorAction Stop
}
.
.
.