Pagination

Overview

When making REST API calls to a specific endpoint using the GET method of the HTTP Client Snap, there might be a lot of results to return. In order to divide the results into multiple pages for easier handling, use the pagination settings. For example, you make a REST API call to return all the pages from a Salesforce instance; the response can be thousands of pages, which is undesirable. You can use the Pagination settings to configure the Has Next field and set the number of pages to fetch to get a specific number of results.

Pagination for POST requests

The HTTP Client Snap does not automatically resend data in subsequent pagination requests. Therefore, we suggest the following solution to efficiently navigate through results from an API that requires the data to be resent with each request.

Problem: Endpoint API requires filter/sort criteria to be re-posted with each call.

Solution:

 

  1. Configure the HTTP Client Snap to make an initial API call (without pagination settings) to fetch the first result set.

  2. Configure the Router snap to perform the following tasks:

    1. Pass through the first result set obtained from the HTTP Client.

    2. Determine if pagination is required based on specific criteria.

  3. Configure the Mapper snap to create an array of page numbers to retrieve.

  4. Utilize the JSON Splitter Snap to convert the page number array into individual documents.

  5. Configure the HTTP Client Snap to make subsequent API calls for the remaining result set. Ensure to exclude pagination settings for each call.

  6. Connect the Union Snap to merge the retrieved results from all the API calls for further processing.

Download this pipeline.

  File Modified

File Example-HTTP -Client-POST-Pagination.slp

Mar 28, 2024 by Kalpana Malladi