Custom Web Services Connector Pagination failing

When I try to implement pagination on a custom web services connector (for Lenel OnGuard using the OpenAccess module), I get an error message: sailpoint.connector.ConnectorException: Error: class java.lang.String cannot be cast to class java.util.Map (java.lang.String and java.util.Map are in module java.base of loader 'bootstrap')

If I remove the pagination config, I can retrieve the results for Page 1 with no error. The response body includes an attribute called page_number with the current page number as well as total_pages with the total number of pages. The page number we want should be passed in as a query param in the URL.

I’ve tried many things, all with the same error message:

Attempt 1:

TERMINATE_IF $NO_RECORDS$
$offset$ = $offset$ + 1
$endpoint.fullUrl$ = "https://[server]/api/access/onguard/openaccess/cardholders?auto_load_badge=false&auto_load_multimedia_object=false&auto_load_access_level=false&auto_load_reader=false&auto_load_timezone=false&auto_load_timezone_interval=false&version=1.6&queue=false&page_size=10&page_number=" + $offset$

Attempt 2:

$nextpage$ = 0
$inc$ = 1
TERMINATE_IF $response.page_number$ == $response.total_pages$
$nextpage$ = $nextpage$ + $inc$
$endpoint.fullUrl$ = "https://[server]/api/access/onguard/openaccess/cardholders?auto_load_badge=false&auto_load_multimedia_object=false&auto_load_access_level=false&auto_load_reader=false&auto_load_timezone=false&auto_load_timezone_interval=false&version=1.0&queue=false&page_size=10&page_number=" + $nextpage$

Attempt 3:

TERMINATE_IF $response.total_pages == $response.page_number
#set($nextPage = $response.page_number + 1)
$endpoint.fullURL = $application.baseUrl$ + $endpoint.contextUrl$ + "&page_number=" + $nextPage

Attempt 4:

$limit$ = 10
TERMINATE_IF $response.total_pages$ == $response.page_number$
$offset$ = $offset$ + 1
$endpoint.fullUrl$ = $application.baseUrl$ + $endpoint.relativeUrl$ + "&page_number=" + $offset$

Any guidance? Thanks in advance!

Can you show example of response with paging attributes?

The response looks like this:

{
    "count": 20,
    "item_list": [
        ...
    ],
    "page_number": 1,
    "page_size": 20,
    "total_items": 22134,
    "total_pages": 1107,
    "version": "1.0"
}

The item_list array contains all of the individual records, and the Root Path on the Response Information tab is se tto $.item_list.

@sup3rmark try this :

$page$ = 1
$pg_limit$ = 100
TERMINATE_IF $RECORDS_COUNT$ < $pg_limit$
$pg_offset$ = $pg_offset$ + $page$
$endpoint.fullUrl$ = https://[server]/api/access/onguard/openaccess/cardholders?auto_load_badge=false&auto_load_multimedia_object=false&auto_load_access_level=false&auto_load_reader=false&auto_load_timezone=false&auto_load_timezone_interval=false&version=1.0&queue=false&page_size=10&page_number=" + $page$

@ipobeidi Same error, unfortunately :frowning:

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

$page$ = 1
$pg_limit$ = 10
TERMINATE_IF $RECORDS_COUNT$ < $pg_limit$
$pg_offset$ = $pg_offset$ + $page$
$endpoint.fullUrl$ = "https://[server]/api/access/onguard/openaccess/cardholders?auto_load_badge=false&auto_load_multimedia_object=false&auto_load_access_level=false&auto_load_reader=false&auto_load_timezone=false&auto_load_timezone_interval=false&version=1.6&queue=false&page_size=10&page_number=" + $pg_offset$

Hi @sup3rmark ,

Try this hope this works,
$page$ = 1
$pg_limit$ = 10
$pg_offset$ = 1
TERMINATE_IF $response.page$ < $response.total_pages$
$pg_offset$ = $pg_offset$ + $response.page$
$endpoint.fullUrl$ = “https://[server]/api/access/onguard/openaccess/cardholders?auto_load_badge=false&auto_load_multimedia_object=false&auto_load_access_level=false&auto_load_reader=false&auto_load_timezone=false&auto_load_timezone_interval=false&version=1.6&queue=false&page_size=10&page_number=” + $pg_offset$

Thanks

Thanks for the suggestion, @Karthikeyan_U, but there is no page attribute in the response, just page_number, and we’d always want page_number < total_pages. Additionally, you’re adding $pg_offset$ to the page number of the response, which would result in skipping most pages. This one’s not going to work either, unfortunately.

Hi @sup3rmark ,

Thanks for the correction, yes it should be a page_number instead of “page”. However, have you tried this URL in Postman and it’s working?

https://[server]/api/access/onguard/openaccess/cardholders?auto_load_badge=false&auto_load_multimedia_object=false&auto_load_access_level=false&auto_load_reader=false&auto_load_timezone=false&auto_load_timezone_interval=false&version=1.6&queue=false&page_size=10&page_number=10

Also, what different attributes are available in the response headers? and what is response Information config: $ or $.item_list?

Updated Paging Code:

$page$ = 1
$pg_limit$ = 10
TERMINATE_IF $response.page_number$ < $response.total_pages$
$pg_offset$ = $response.page_number$ + 1
$endpoint.fullUrl$ = “https://[server]/api/access/onguard/openaccess/cardholders?auto_load_badge=false&auto_load_multimedia_object=false&auto_load_access_level=false&auto_load_reader=false&auto_load_timezone=false&auto_load_timezone_interval=false&version=1.6&queue=false&page_size=10&page_number=” + $pg_offset$

Yes, it works as expected in Postman.

The response headers have nothing of any use as far as pagination, unfortunately. As mentioned above, the Root Path on the Response Information tab is se tto $.item_list.

Unfortunately, still no dice with that updated code.

Hey all,
Thanks for the suggestions here. Turns out, the issue was actually with the Custom Authentication configuration, and not actually a pagination issue at all. That said, here’s the final (working) pagination config:

TERMINATE_IF $response.page_number$ == $response.total_pages$
$offset$ = $offset$ + 1
$endpoint.fullUrl$ = $application.baseUrl$ + $endpoint.relativeUrl$ + "&page_number=" + $offset$