# Href pagination not working

**URL:** <https://developer.sailpoint.com/discuss/t/href-pagination-not-working/88764>\
**Category:** SHF Discussion and Questions\
**Tags:** webservice-connector, connectors, aggregation, sailpoint-identity-security, apis\
**Created:** [November 6, 2024, 9:42am UTC](https://developer.sailpoint.com/discuss/t/href-pagination-not-working/88764 "2024-11-06T09:42:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karthish](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@Karthish](https://developer.sailpoint.com/discuss/u/Karthish)\
**Post date:** [November 6, 2024, 9:42am UTC](https://developer.sailpoint.com/discuss/t/href-pagination-not-working/88764/1 "2024-11-06T09:42:07Z")

</div>

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:

```auto
{
  "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 :

```auto
$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!

---

<div class="post-metadata">

**Author:** ![pradeep1602](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/pradeep1602/32/30858_2.png) [@pradeep1602](https://developer.sailpoint.com/discuss/u/pradeep1602)\
**Post date:** [November 7, 2024, 1:19am UTC](https://developer.sailpoint.com/discuss/t/href-pagination-not-working/88764/2 "2024-11-07T01:19:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vguleria](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/vguleria/32/7884_2.png) [@vguleria](https://developer.sailpoint.com/discuss/u/vguleria)\
**Post date:** [November 7, 2024, 9:17am UTC](https://developer.sailpoint.com/discuss/t/href-pagination-not-working/88764/3 "2024-11-07T09:17:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![udayputta](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/udayputta/32/14195_2.png) [@udayputta](https://developer.sailpoint.com/discuss/u/udayputta)\
**Post date:** [November 7, 2024, 2:45pm UTC](https://developer.sailpoint.com/discuss/t/href-pagination-not-working/88764/4 "2024-11-07T14:45:34Z")

</div>

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

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Karthish](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@Karthish](https://developer.sailpoint.com/discuss/u/Karthish)\
**Post date:** [November 13, 2024, 2:08pm UTC](https://developer.sailpoint.com/discuss/t/href-pagination-not-working/88764/5 "2024-11-13T14:08:11Z")

</div>

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$

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [January 12, 2025, 2:08pm UTC](https://developer.sailpoint.com/discuss/t/href-pagination-not-working/88764/6 "2025-01-12T14:08:57Z")

</div>

Closed on January 12, 2025, 2:08pm UTC

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