# Custom Web Services Connector Pagination failing

**URL:** <https://developer.sailpoint.com/discuss/t/custom-web-services-connector-pagination-failing/58169>\
**Category:** SHF Discussion and Questions\
**Tags:** webservice-connector, aggregation, sailpoint-identity-security\
**Created:** [May 28, 2024, 3:55pm UTC](https://developer.sailpoint.com/discuss/t/custom-web-services-connector-pagination-failing/58169 "2024-05-28T15:55:12Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sup3rmark](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/sup3rmark/32/36229_2.png) [@sup3rmark](https://developer.sailpoint.com/discuss/u/sup3rmark)\
**Post date:** [May 28, 2024, 3:55pm UTC](https://developer.sailpoint.com/discuss/t/custom-web-services-connector-pagination-failing/58169/1 "2024-05-28T15:55:12Z")

</div>

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:

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

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

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

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

---

<div class="post-metadata">

**Author:** ![kjakubiak](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/kjakubiak/32/7052_2.png) [@kjakubiak](https://developer.sailpoint.com/discuss/u/kjakubiak)\
**Post date:** [May 28, 2024, 4:16pm UTC](https://developer.sailpoint.com/discuss/t/custom-web-services-connector-pagination-failing/58169/2 "2024-05-28T16:16:29Z")

</div>

Can you show example of response with paging attributes?

---

<div class="post-metadata">

**Author:** ![sup3rmark](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/sup3rmark/32/36229_2.png) [@sup3rmark](https://developer.sailpoint.com/discuss/u/sup3rmark)\
**Post date:** [May 28, 2024, 5:18pm UTC](https://developer.sailpoint.com/discuss/t/custom-web-services-connector-pagination-failing/58169/3 "2024-05-28T17:18:24Z")

</div>

The response looks like this:

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

---

<div class="post-metadata">

**Author:** ![ipobeidi](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/ipobeidi/32/16000_2.png) [@ipobeidi](https://developer.sailpoint.com/discuss/u/ipobeidi)\
**Post date:** [May 28, 2024, 5:20pm UTC](https://developer.sailpoint.com/discuss/t/custom-web-services-connector-pagination-failing/58169/4 "2024-05-28T17:20:33Z")

</div>

@sup3rmark try this :

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

```

---

<div class="post-metadata">

**Author:** ![sup3rmark](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/sup3rmark/32/36229_2.png) [@sup3rmark](https://developer.sailpoint.com/discuss/u/sup3rmark)\
**Post date:** [May 28, 2024, 5:25pm UTC](https://developer.sailpoint.com/discuss/t/custom-web-services-connector-pagination-failing/58169/5 "2024-05-28T17:25:22Z")

</div>

@ipobeidi Same error, unfortunately ☹

`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')`

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

```

---

<div class="post-metadata">

**Author:** ![Karthikeyan\_U](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/karthikeyan_u/32/23649_2.png) [@Karthikeyan\_U](https://developer.sailpoint.com/discuss/u/Karthikeyan_U)\
**Post date:** [May 28, 2024, 6:01pm UTC](https://developer.sailpoint.com/discuss/t/custom-web-services-connector-pagination-failing/58169/6 "2024-05-28T18:01:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sup3rmark](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/sup3rmark/32/36229_2.png) [@sup3rmark](https://developer.sailpoint.com/discuss/u/sup3rmark)\
**Post date:** [May 28, 2024, 6:14pm UTC](https://developer.sailpoint.com/discuss/t/custom-web-services-connector-pagination-failing/58169/7 "2024-05-28T18:14:18Z")

</div>

> [@Karthikeyan\_U](#):
>
> $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 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.

---

<div class="post-metadata">

**Author:** ![Karthikeyan\_U](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/karthikeyan_u/32/23649_2.png) [@Karthikeyan\_U](https://developer.sailpoint.com/discuss/u/Karthikeyan_U)\
**Post date:** [May 28, 2024, 6:27pm UTC](https://developer.sailpoint.com/discuss/t/custom-web-services-connector-pagination-failing/58169/8 "2024-05-28T18:27:18Z")

</div>

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$

---

<div class="post-metadata">

**Author:** ![sup3rmark](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/sup3rmark/32/36229_2.png) [@sup3rmark](https://developer.sailpoint.com/discuss/u/sup3rmark)\
**Post date:** [May 28, 2024, 6:43pm UTC](https://developer.sailpoint.com/discuss/t/custom-web-services-connector-pagination-failing/58169/9 "2024-05-28T18:43:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sup3rmark](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/sup3rmark/32/36229_2.png) [@sup3rmark](https://developer.sailpoint.com/discuss/u/sup3rmark)\
**Post date:** [May 29, 2024, 4:08am UTC](https://developer.sailpoint.com/discuss/t/custom-web-services-connector-pagination-failing/58169/10 "2024-05-29T04:08:03Z")

</div>

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:

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

```

---

<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:** [July 28, 2024, 4:08am UTC](https://developer.sailpoint.com/discuss/t/custom-web-services-connector-pagination-failing/58169/11 "2024-07-28T04:08:31Z")

</div>

Closed on July 28, 2024, 4:08am UTC

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