API v3 pagination error

I wrote some Python scripts to query the v3 API, but I can’t fix the pagination. It only retrieves the first page, and if I configure the pagination, it gets stuck in an infinite loop.
The code is in the image

I think you need to use sort and searchAfter parameters

See: search-post | SailPoint Developer Community

limit and offset are part of QUERY PARAMETERS and not BODY. The code is sending the two values as part of body, hence it is getting stuck in an infinite loop.

Instead pass those 2 values as query parameters. For example,

search_payload = {
    "indices": ["identities"],
    "query": {"query": "*"},
    "fields": ["name", "displayName"]
}


query_params = {
    "limit": limit,
    "offset": offset
}

try:
    response = requests.post(
        search_url,
        headers=headers_post,
        json=search_payload,
        params=query_params, # instead of passing those values in the request body
        verify=False
    )
    response.raise_for_status()
    pagina = response.json()

    # rest code will remain the same

Also, as mentioned by Jason, use sort and searchAfter for records past 10k.

Start with offset and limit as query params. Once you hit the 10k records, you need to switch to searchAfter and sorter as suggested in earlier posts

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