Pagination not working properly - infinite loop

I’m newbie in n8n and I’m trying to use HTTP Request node to download info from an API from Agendor CRM. When I use a GET with manual parameters everything seems to be allright, but when I tried using pagination to get data from multiple pages, it’s not working the way I want and I don’t know how to solve.
The Agendor API sent me the next page link, and when there is no next page this link doesn’t exist (as you can see in the images).

I set up Pagination mode as ‘Response Contains Next URL’ and pagination complete when ‘Response is empty’.

When I execute this node it doesn’t stop, so I set Max Pages to a 100 and when checked the data it seems to loop until it completed a 100 pages.
What I’m missing?

Information on your n8n setup

  • I’m using n8n service but got this same behavior on a n8n on a VPS

I can not run the api from my end.

But I can explain why the your setting not working.

Because your Response Is Not Empty when the next page coming.

It still show the response but not having the field $response.body.links.next

So the Pagination Complete When $response.body.links.next is not set.

1 Like

Thank you very much for your response!

I will leave the complete setup, so if a newbie in n8n and javascript has the same problem, can view the solution:

the expression !$response?.body?.links?.next returns true when there is no next link.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.