cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Pagination in HTTP Client snap

Pakhi
New Contributor III

Hi All,
I am working with HTTP client snap and this is my first snap in the pipeline and i am using GET method to read data from API.
I have to make sure data from all pages gets captured from source and for that i have to use pagination.

Can anyone help me in this as i have never used this function.

6 REPLIES 6

AleksandarAngel
Contributor III

Hello @Pakhi,

It would be helpful if you can provide us with response sample, so we can determine what are going to be the properties on which we will set up the pagination.

In the meantime you can check the offical HTTP Client Snap documentation.
https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/2614591489/HTTP+Client#Pagination

BR,
Aleksandar.

jhipp
New Contributor

Iโ€™m in a similar position and canโ€™t seem to figure out how to iterate through all of the pages with the information I get from the API. The API Iโ€™m calling is very barebones, not including the total number from the call or page number. Hereโ€™s a example response:

[
    {
        "enrollment_id": 1223524,
        "content_type": "Store Purchase",
        "module_name": "Module 1",
        "user": {
            "id": 111111,
            "first_name": "TEST",
            "last_name": "PERSON 1",
            "email": "example@test.com"
        },
        "campaign_name": "Campaign 1",
        "enrollment_date": "2023-02-15T15:10:57.000Z",
        "start_date": null,
        "completion_date": null,
        "status": "Not Started",
        "time_spent": 0,
        "policy_acknowledged": false
    },
    {
        "enrollment_id": 1223525,
        "content_type": "Store Purchase",
        "module_name": "Module 1",
        "user": {
            "id": 111112,
            "first_name": "TEST",
            "last_name": "PERSON 2",
            "email": "example@test.com"
        },
        "campaign_name": "Campaign 1",
        "enrollment_date": "2023-02-15T15:10:57.000Z",
        "start_date": "2023-02-18T19:43:31.000Z",
        "completion_date": "2023-02-18T20:08:04.000Z",
        "status": "Passed",
        "time_spent": 1574,
        "policy_acknowledged": false
    }
]

Here are my original Query Parameters:
image

But the problem is I canโ€™t figure out how to increment the page parameter in the pagination section. Iโ€™ve figured out how to trigger pagination via the $entity.length comparison, but not how to grab the next page:
image

Any help is greatly appreciated.

How do you know there are more pages to request? Iโ€™m only seeing two results in the first page, but you specified 500 results per page. Doesnโ€™t that mean there are no more results?

jhipp
New Contributor

I truncated the results for simplicity to show thereโ€™s no total_results or pages in my response. I know there are 3 pages of data (~1300 results) because Iโ€™ve run API request through postman.

To answer your first question, the only way I know thereโ€™s more to request is if there are 500 results returned on a page (max defined by the API), then Iโ€™d try to pull the next page. Rinse and repeat until the results returned is not 500. I realize thereโ€™s a potential for a campaign to have a number of results divisible by 500 and will make a call that will result in 0 responses.