Set up pagination for Web Service SaaS Source

Hi,
I’ve run into some issues setting up pagination for a web service.

The URL has this format:

{{baseURL}}/v1/people?type=internal&count=10&startPage=2

And the response body:

{
    "totalResults": 6425,
    "hasMoreResults": true,
    "startIndex": 11,
    "itemsPerPage": 10,
    "results": [
          .....
     ]
}

First call startIndex is 1, then 11 and so on while startPage has to be increased by 1 so 1, 2,3 4… until hasMoreResults == false.

I’m trying to use the default pagination to avoid having to create a rule.

In ISC I have tried both these settings in paging steps but I only get the fist 10 users.

Initial Page Offset: 1
Page Size: 10

Test 1:

TERMINATE_IF ($response.hasMoreResults$ == false)
$sysparm_offset$ = $sysparm_offset$  + 1
$endpoint.fullUrl$ = $application.baseUrl$ + "/v1/people?type=internal&count=10&startPage=" + ($sysparm_offset$)

Test 2:

TERMINATE_IF ($response.hasMoreResults$ == false)
$sysparm_offset$ = $sysparm_offset$  + 1
$endpoint.fullUrl$ = $application.baseUrl$ + "/v1/people?type=internal&count=10&startPage=" + ($response.startIndex$ % 10)

Do anyone see why this is failing and know how I should configurate the pagination in ISC?

Hey Jenny,

As per your requirement, your first pagination setting looks correct. Some minor changes, is try removing the parenthesis from around, $sysparam_offset$.

So, it should look something like,

TERMINATE_IF ($response.hasMoreResults$ == FALSE)
$sysparm_offset$ = $sysparm_offset$  + 1
$endpoint.fullUrl$ = $application.baseUrl$ + "/v1/people?type=internal&count=10&startPage=" + $sysparm_offset$

FYR, this is an example of valid pagination.

$limit$ = 100
TERMINATE_IF ( $NO_RECORDS$ == TRUE )
$offset$  = $offset$ + $limit$
$endpoint.fullUrl$ = $application.baseUrl$ + "/users?count=100&startIndex=" + $offset$