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!