{tenant}api.identitynow.com/beta/search Not returning all the identities

Hello ,

I am writing a PowerShell Script that will generate a .csv file of identities with attributes “stale = true”.
This script is giving me only 250 identities but there are more than 1000 identities with this attribute being true.

$SearchURL = "https://sailpoint.api.identitynow.com/beta/search"
$searchHeaders = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$searchHeaders.Add("Content-Type", "application/json")
$searchHeaders.Add("Accept", "application/json")
$searchHeaders.Add("Authorization", "Bearer $accessToken")
$searchBody = '{
      "indices": [
        "identities"
      ],
      "query": {
        "query": "attributes.stale:True",
        "fields": [
          "displayName"
        ]
      }
    }'
    $searchResp = Invoke-RestMethod $SearchURL -Method 'POST' -Headers $searchHeaders -Body $searchBody
    $Output = foreach ($data in $searchResp) {
      New-Object -TypeName PSObject -Property @{
        name = $data.displayName
        staffId = $data.attributes.staffId         
        
        
      } | Select-Object name, staffId      
    }
    $Output

Could anyone tell what am I missing here to get all identities.

Yeah, it’s probably because missing the limit parameter in your URI. Try adding it and running your code again. You can check out the API docs here for more details: search-post | SailPoint Developer Community

ex: https://sailpoint.api.identitynow.com/beta/search?limit=10000

1 Like

Default limit is 250, that is why API is returning 250 identities.

Check the API doc for more information.

– Krish

1 Like

Thank you @kalyan_dev32
It worked.

1 Like

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