We’re using http request node to fetch data using API. The data volume is high and I tried pagination feature in n8n but it’s not working. The {{$pagecount + 1}} is not working. If I’m giving number 0 or 1 in pagenumber parameter. It’s not getting changed and If I leave the pagenumber empty, i’m getting invalid json error.
Hi @pokonut the correct pagination variable is $pageCount
Also your JSON parameter is being empty passed like “pageNumber”: which is not a valid syntax in http node and also change the pageNumber inside the RequestBody expression, since it’s not a separate parameter.
pageNumber is a parameter defined by the third-party API. If I change this parameter name, the request fails. I can pass the value “1” to it without any issue.
In the n8n pagination settings, I used $pageCount as the variable. However, the problem is that the same API request is being triggered repeatedly without updating the $pageCount value.
I added a condition to throw an error if the same page is requested five times in a row. Now the workflow stops with this exact error: “same request passed / same response generated 5x.”
@pokonut Have you tried using pagination in HTTP node? and setting that API parameter pageNumber inside your request body? So that like each new request would increase the counter and would fetch new page, i guess that is what i can think of..
Hey @pokonut the issue here is that your `pageNumber` is buried inside a URL-encoded JSON string in the `RequestBody` form field, so n8n’s built-in pagination can’t actually reach it to increment it. The pagination feature works when the page parameter is a direct query param or body field, but yours is nested inside that encoded JSON blob which makes it tricky.
What you’ll probably need to do is build the RequestBody dynamically using an expression. In the body parameters where you have RequestBody, you’d need to construct the JSON string with the pageNumber set to `{{ $pageCount }}` and then URL-encode the whole thing. Something like `{{ encodeURIComponent(JSON.stringify({ “orderNo”: “”, “statuses”: [“CONFIRMED”,“PENDING”], “pageNumber”: $pageCount, … })) }}` for the RequestBody value. That way each pagination iteration actually updates the page number inside your encoded payload.
Alternatively if that gets messy you could skip the built-in pagination entirely and use a Loop Over Items node or just a simple loop with a Code node that increments a counter and keeps fetching until you get an empty response, sometimes that’s cleaner when the API has a weird request format like this one.
so, I created a variable ‘page’ (using set node), set it to 1, passed as {{ $json.page}} inside the request body. The request generated response successfully. I used ‘loop’ node incrementing the ‘page’ variable, skipping the built-in pagination. It worked.