Href pagination not working

I am attempting to implement href-based pagination, but despite my efforts, the accounts are not appearing. Below is the body of the Postman request and the pagination logic I have tried:

{
  "links": {
    "self": {
      "href": "/api/v2/people?cursor=eyJwYWdlIjoyfQ.Zx_e8w.GsCjlc-XHWk4aznc1yNz0vwG80w"
    },
    "next": {
      "href": "/api/v2/people?cursor=eyJwYWdlIjozfQ.Zys0mQ.ZpEebOSHOSJwjEh5NR2OjCOqjso",
      "meta": {
        "cursor": "eyJwYWdlIjozfQ.Zys0mQ.ZpEebOSHOSJwjEh5NR2OjCOqjso"
      }
    },
    "prev": {
      "href": "/api/v2/people?cursor=eyJwYWdlIjoxfQ.Zys0mQ.-YxQftRvVDoyOtkF8LtegI2a4wU",
      "meta": {
        "cursor": "eyJwYWdlIjoxfQ.Zys0mQ.-YxQftRvVDoyOtkF8LtegI2a4wU"
      }
    }
  }
}

Pagination Logic :

$cursor$ = ""
$accountCount$ = 0
$endpoint.fullUrl$ = $application.baseUrl$ + "/api/v2/people?cursor=" + $cursor$
$response$ = (HTTP GET request to $endpoint.fullUrl$)
TERMINATE_IF $RECORDS_COUNT$ == 0
$accountCount$ = $accountCount$ + $RECORDS_COUNT$
$nextCursor$ = $response.links.next.meta.cursor$
TERMINATE_IF !$nextCursor$
$cursor$ = $nextCursor$
$endpoint.fullUrl$ = $application.baseUrl$ + "/api/v2/people?cursor=" + $cursor$

Despite trying to implement this logic, the accounts are not being fetched correctly. This could be due to one of the following:

  • The $RECORDS_COUNT$ may not be correctly counting the records returned.
  • The pagination logic may not be properly handling the cursor values or the next page might not be fetched as expected.

If anyone has suggestions or insights on how to fix this issue, your help would be appreciated!

Hi
Can you share the sample the response for your api call?
Can you also double check the json path for next cursor variable if it is correct or not.

Also try: TERMINATE_IF $nextCursor$ == NULL if that helps
Thanks
Pradeep

Hi @Karthish

Welcome to SailPoint community.

In order to help you further, could you please provide some more information about the response body and what should be the next url. With the logic you have provided, believe we can make it easier and then make it work but please provide some more information.

Thank You.
Regards
Vikas

1 Like

To me it looks like the pagenation logic is not correct. If you are looking for a sample here it is

TERMINATE_IF $NO_RECORDS$
TERMINATE_IF $offset$ > $response.totalCount$
$endpoint.fullUrl$ = $application.baseUrl$ + "/v3/accounts?count=" + $limit$ + "&startIndex=" + $offset$
$offset$ = $offset$ + $limit$

Where limit is 30 and offset is 0
1 Like

Was able to resolve it by using the below Logic

TERMINATE_IF $response.links.next.meta.cursor$ == NULL
$cursor$ = $response.links.next.meta.cursor$
$endpoint.fullUrl$ = $application.baseUrl$ + “/people?cursor=” + $cursor$

1 Like