I’ve tried the following paginations but both attempts would stop at 110 or 100 users.
Stopping at 100 accounts
TERMINATE_IF $response.links.next.data.cursor$ == NULL
$cursor$ = $response.links.next.data.cursor$
$endpoint.fullUrl$ = $application.baseUrl$ + “"/companies/XXXXXXX/users?cursor=” + $cursor$
Stopping at 110 accounts
$sysparm_limit$ = 100
TERMINATE_IF $RECORDS_COUNT$ < $sysparm_limit$
$sysparm_offset$ = $sysparm_offset$ + $sysparm_limit$
$endpoint.fullUrl$ = $application.baseUrl$ + "/companies/xxxxxxxxx/users?sysparm_fields=sys_id&sysparm_limit=100&sysparm_offset=" + $sysparm_offset$
Arshad
(Arshad Moghul)
May 22, 2025, 9:36am
2
@DedrickTai , Can you share more details on how the JSON response looks like from postman for this API? It’d be great if you can provide that JSON response here so that we can figure out the issue with this logic.
Thanks,
Arshad.
hi @DedrickTai can you try below
For Cursor-Based Pagination
IF $response.links.next.data.cursor$ != NULL
$cursor$ = $response.links.next.data.cursor$
$endpoint.fullUrl$ = $application.baseUrl$ + "/companies/XXXXXXX/users?cursor=" + $cursor$
ELSE
TERMINATE
Or, if links.next.href
is available:
IF $response.links.next.href$ != NULL
$endpoint.fullUrl$ = $response.links.next.href$
ELSE
TERMINATE
For Offset-Based Pagination
$sysparm_limit$ = 100
IF $RECORDS_COUNT$ < $sysparm_limit$
TERMINATE
ELSE
$sysparm_offset$ = $sysparm_offset$ + $sysparm_limit$
$endpoint.fullUrl$ = $application.baseUrl$ + "/companies/xxxxxxxxx/users?sysparm_limit=" + $sysparm_limit$ + "&sysparm_offset=" + $sysparm_offset$
SASM21
(Sanjeev Shukla)
May 22, 2025, 1:06pm
4
Hi @DedrickTai You need to setup offset and limit in such a way in the URL sot hat it can paginate through next set of records till all the records are fetched , you need to put that logic in the above code.
$endpoint.fullUrl$ = $application.baseUrl$ + “/companies/xxxxxxxxx/users?sysparm_fields=sys_id&sysparm_limit=100&sysparm_offset=” + $sysparm_offset$
based on the documentation It does support href. would I need to modify my context url? I tried
IF $response.links.next.href$ != NULL
$endpoint.fullUrl$ = $response.links.next.href$
ELSE
TERMINATE
But in progress status just spins without giving any accounts