I’m trying to set up pagination for the SendGrid API’s unsubscribe endpoint in n8n desktop version, but I’m unable to get the pagination working correctly using the HTTP Request node’s built-in pagination options.
Type: Offset
Tried using $pageCount * 500 for offset
Result: Returns same data multiple times
URL Pagination:
Type: URL
Tried extracting next URL from Link header
Result: Unable to get it working correctly
Complete Expression:
Tried using {{ !$response.headers.link?.includes(‘rel=“next”’) }}
Result: Pagination doesn’t stop correctly
How can I properly configure the HTTP Request node’s pagination settings to work with SendGrid’s API? The API provides next/prev/first/last URLs in the Link header - is there a way to utilize this with n8n’s built-in pagination?
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!
I’m trying to picture how the response payload looks like. Could you paste an example of the whole payload returned in response to a single request (excluding the actual data)? I haven’t come across linked headers before.
Thank you for the suggestion! I created a proper loop and didn’t even need to need the links from the response.
However, I’ve encountered another issue: Once I completed all the loops, I was certain that the merge node could combine all the items into one from the loop. I’m pretty sure there’s a fix for this, but I’m really stuck at the moment. Do you have any suggestions?
I am using the “Choose Branch” mode in the Merge Node. I tried with others, too but to no avail.
I know this is a different kind of issue, but it is still relevant to paginating and actually making sure the data is aggregated in the output.
Hey @dan1 , no, Merge node cannot combine that data as it’s produced by different iterations (72 in your case, one item in each iteration). For Merge to be able to merge/combine the data you need to have them all as part of the same iteration, which is hardly possible to achieve with this approach. You could engage Code node with some Javascript logic to process all the iterations but how do you signal that all the iterations have completed?
I would suggest to come back to the solution I laid out.