Hello, i have a problem.
I have a api call with pagination in body part of http request. This is the official documentation for call:
this is my node
the problem is that all pages with same contents. Help please, what im doing wrong?
Your “pagination complete when” expression is: {{!$response.body.cursor.total > 100}} This would mean pagination is complete “when the total is 100 or less.” If the total is the count of items in a page, it would ALWAYS be 100 or less with a limit of 100.
The documentation seems to suggest that pagination is complete when “total is less than limit”, meaning the page did not have a full 100 items, so it is the last page. Perhaps the expression should be: {{ $response.body.cursor.total < 100 }}, which would evaluate to true only on the last page (even if that page has zero items).
The body of the next request is formulated with 2 different types of input. This might work, BUT it’s hard to tell what n8n is actually sending. It may be one (JSON) or the other (Pagination->Parameters-Body NV-pairs). To see what is actually getting sent, you could watch the requests by passing the http traffic through a proxy. That might give you an idea whether the request looks right, or if you might need to JUST do the JSON option as an expression like this:
{
"settings": {
"cursor": {
"limit": 100,
"nmID": "{{ $response.body.cursor.nmID }}",
"updatedAt": "{{$response.body.cursor.updatedAt }}"
},
"filter": {
"withPhoto": -1
}
}
}
how i do JSON option like this if i dont have nmID and updatedAt in first request
Just did a bit of testing to see how it’s working and I don’t think it matters whether it’s the first request because the “special”, pagination-related expression variables like $response and $pageCount don’t seem to EVER be in scope when the JSON body is resolved, even on the subsequent requests.
I also tested the way you originally had it configured and captured the body n8n is sending using MITMPROXY. This is what got sent on the 2nd request, which is really NOT what you would need. It appears that dot-notation isn’t supported for those parameters set to Type Body.
{
"settings": {
"cursor": {
"limit": 100,
"nmID": "",
"updatedAt": ""
},
"filter": {
"withPhoto": -1
}
},
"settings.cursor.nmID": abc123,
"settings.cursor.updatedAt": 1748834518
}
If I think of some other way to work around this, I’ll post it here, but right now I’m thinking there might not be a way to make the HTTP Request pagination feature work with this API.
mayby, i can write a json/python script, but i didnt found a lib to use http in n8n’s JS
Axios is built in. If you are self-hosted, you just need to add environment variable: NODE_FUNCTION_ALLOW_BUILTIN=axios and use JS (not python) in the Code node. Axios examples are all over so search or chatgpt for something that matches what you want to do.
im using pm2 to deploy n8n on my machine, im added NODE_FUNCTION_ALLOW_BUILTIN=axios in env by pm2 start n8n --env NODE_FUNCTION_ALLOW_BUILTIN=axios but Code node says Cannot find module
I looked back at a setup where I had it working. For some reason I guess axios is considered an external library even though it is already npm installed with n8n’s core build. Try this instead.
NODE_FUNCTION_ALLOW_EXTERNAL=axios
So, it didn’t worked. For unknown reason im can’t set NODE_FUNCTION_ALLOW_EXTERNAL=axios in env, im using same method that i used to set NODE_FUNCTION_ALLOW_BUILTIN=axios but it ignoring NODE_FUNCTION_ALLOW_EXTERNAL