- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2023 07:46 PM
Hi All,
I created a REST message for the GET call (to pull data from 3rd party) and tested it with mutual authentication. Mutual authentication is working fine.
I created Flow, Subflow, and action. In that action, I am using the script step for parsing, Pagination supports only for REST step.
I can not use the REST step because of mutual authentication. Is there any other better way to do pagination?
Thanks
Ra
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2023 06:38 AM
Hello @Raji9 ,
If you need to implement pagination for a REST message using mutual authentication, you can achieve this by using a scripted approach. Here is the basic example for your reference
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var pageNumber = request.queryParams.page || 1; // Get the page number from the request
var pageSize = 10; // Set your desired page size
// Calculate the offset based on the page number and page size
var offset = (pageNumber - 1) * pageSize;
// Make the REST message request with pagination parameters
var restMessage = new sn_ws.RESTMessageV2();
restMessage.setEndpoint('https://example.com/api/data');
restMessage.setHttpMethod('get');
restMessage.setRequestHeader('Authorization', 'Bearer YOUR_ACCESS_TOKEN');
restMessage.setQueryParameter('page', pageNumber);
restMessage.setQueryParameter('page_size', pageSize);
// Execute the REST message
var response = restMessage.execute();
// Handle response and pagination logic here
// Send the aggregated response back to the caller
response.setContentType('application/json');
response.setStatus(200);
response.setBody(/* Aggregated data */);
})(request, response);
Kindly mark correct and helpful if applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2023 12:49 AM
Hi @Raji9
it's the first time hearing the REST step cannot be used due to mutual authentication.
Apart from that you could try Data Stream actions which allow pagination. On my page https://www.servicenow.com/community/now-platform-articles/platform-integration-hub-knowledge-amp-tr... you will find some resources regarding that topic.
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2023 07:47 AM
Hi Maik,
Thanks. I have to use the REST step in order to use Data stream action, That is why I am looking for another approach.
Thanks
Raji

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2023 06:38 AM
Hello @Raji9 ,
If you need to implement pagination for a REST message using mutual authentication, you can achieve this by using a scripted approach. Here is the basic example for your reference
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var pageNumber = request.queryParams.page || 1; // Get the page number from the request
var pageSize = 10; // Set your desired page size
// Calculate the offset based on the page number and page size
var offset = (pageNumber - 1) * pageSize;
// Make the REST message request with pagination parameters
var restMessage = new sn_ws.RESTMessageV2();
restMessage.setEndpoint('https://example.com/api/data');
restMessage.setHttpMethod('get');
restMessage.setRequestHeader('Authorization', 'Bearer YOUR_ACCESS_TOKEN');
restMessage.setQueryParameter('page', pageNumber);
restMessage.setQueryParameter('page_size', pageSize);
// Execute the REST message
var response = restMessage.execute();
// Handle response and pagination logic here
// Send the aggregated response back to the caller
response.setContentType('application/json');
response.setStatus(200);
response.setBody(/* Aggregated data */);
})(request, response);
Kindly mark correct and helpful if applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2023 07:41 AM
Hi Mahajan,
Thanks. I am using a for loop in the script step(flow designer) for iteration. Do I need to remove if I use your pagination script? Also, I am using each in the sub-flow to update the data(output from action) to import data into the import set table.
And what logic should go here?
Handle response and pagination logic here
Thanks
Raji