cancel
Showing results for 
Search instead for 
Did you mean: 

How to compare previous URI in pagination in HTTP Client?

Andrei_Y
New Contributor III

I have an issue with an infinite loop in pagination. API Server returns a next URI which matches the previous URI. It can happen on any pages. For example, HTTP client fetched 10 pages but the page 10 contains the next URI which matches the previous URI. I want to stop in order to avoid an infinite loop but I don't know how get the previous URI in Pagination section. Do you have any ideas how to do it?

For example, URI request = https://hostname.com/?after=bbbb returns:

 

{
    "entity": {
      "data": [],
      "paging": {
        "next": "https://hostname.com/?after=bbbb",
        "previous": "https://hostname.com/?before=aaaa"
      }
}

 

 

 

2025-03-21_184317.jpg

2 REPLIES 2

koryknick
Employee
Employee

@Andrei_Y - can you download the actual output and mask the base url so I have a better idea of the actual output produced and where it gets into infinite looping?

To break the infinite loop, you can always use something like the following in the Has Next property:

$snap.out.totalCount < 10

Andrei_Y
New Contributor III

I cannot use 

$snap.out.totalCount

because I don't know how many pages I need to fetch and it depends on how many a Facebook page contains posts. I attached a file with response from Facebook Graph API where I replaced unique strings with <---111--->, <---222-->, <---333--->, <---444--> and hid data with <---hidden--->. Facebook support ignores the issue. The _debug contains requestLine in HTTP Client which I might use but it is not available in the Pagination section.

(Virus scan in progress ...)