Pagination for Tableau with Web Services Connection

We are trying to set up a Web Services Connector to Tableau and not able to set the Page Number for Pagination during Account Aggregation. Single page Aggregation works fine and first 1000 accounts are aggregated successfully
URL is in the format:

https://tableau.localdomain.com/api/3.23/sites/$application.siteId$/users?pageSize=1000&pageNumber=1

Response:

<?xml version='1.0' encoding='UTF-8'?>

<tsResponse xmlns="http://tableau.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api https://help.tableau.com/samples/en-us/rest_api/ts-api_3_23.xsd">
    <pagination pageNumber="1" pageSize="10" totalAvailable="7583"/>
    <users>
        <user email="xxxxxxxxx" externalAuthUserId="" fullName="xxxxxx" id="xxxxx" lastLogin="xxxxxxx" name="xxxxxxx" siteRole="Viewer" locale="" language="en">
            <domain name="xxxxxxxxxxxxxxxxx"/>
        </user>
        more users.........
    </users>
</tsResponse>

Tried following in pagination

TERMINATE_IF $RECORDS_COUNT$ < $pageSize$
$pageNumber$ = $pageNumber$ + 1
$endpoint.fullUrl$ = $application.baseUrl$ + "/api/3.23/sites/SITE_ID/users?pageSize=" + $pageSize$ + "&pageNumber=" + $pageNumber$

but getting this error

sailpoint.connector.ConnectorException: Error: class java.lang.Integer cannot be cast to class java.lang.String (java.lang.Integer and java.lang.String are in module java.base of loader ‘bootstrap’)

Does you first call has 1000 for page size? And your terminate condition should be like records <= totalSize and these page size and page numbers are returned as string. Cast them to int for page calculation.

Thanks @lampard08
How do you cast a string to integer under pagination settings?

Try this :

int pageSize = Integer.parseInt($pageSize$)

int pageNumber = Integer.parseInt($pageNumber$)

TERMINATE_IF $RECORDS_COUNT$ < <hardCode the value for testing>
$pageNumber$ = $pageNumber$ + 1
$endpoint.fullUrl$ = $application.baseUrl$ + "/api/3.23/sites/SITE_ID/users?pageSize=" + $pageSize$ + "&pageNumber=" + $pageNumber$

Your casting error was seen in another thread. Think it was solved by getting the pageNumber from the $response.

https://developer.sailpoint.com/discuss/t/custom-web-services-connector-pagination-failing/58169/11

i.e. Paging by Response Markers:

Thanks @David_Norris

Based on the responses in the post you linked, this setting worked

TERMINATE_IF $RECORDS_COUNT$ < 1000
$offset$ = $offset$ + 1
$endpoint.fullUrl$ = $application.baseUrl$ + "/api/3.23/sites/SITE_ID/users?pageSize=1000&pageNumber=" + $offset$