Just started learning how to use n8n and am really excited to be able to apply it on my work. I’m also relatively new to APIs and only knows basic javascript.
That said, I was using n8n to get data from an API and upload to Onedrive. I was able to setup most of the things just fine. The problem I’m having is that the API I am calling is always returning the last page even if you set the page parameter in the API call to more than what it actually returns. I know it is more, because it does return a page_count that says how many pages are in the response.
I’ve set the “Pagination Complete When” to:
{{ $response.body.data.page_info.page_count == ($pageCount + 1) }}
This does not work as the loop still continues. N8n does stop after receiving the same response 5 time in a row. But I want to know if there is a value I could use to end the call. This is all I have to learn of the API am using:
Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.
```
<your workflow>
```
That implies to any JSON output you would like to share with us.
Make sure that you have removed any sensitive information from your workflow and include dummy or pinned data with it!
You would typically enage $pageCount when you need to tell HTTP Request node to get the next page. To stop pagination you likely need to rely on different strategy.
I suspect you need to look for empty data, something like this (depending on the actual data structure returned):