HTTP Request Pagination not working

Hi there,

I have tried to use the pagination feature of the http request node.
But it is not working as the http Request node does not get the data from the response to get the “next URL”.

This are the settings right now:

I try to get the next URL by accessing:
{{ $response.body.Response.nextpage }}

When I make an api call without the pagination feature I get all data and the next URL as well.

When I make the api call with the pagination feature I get an empty data response… (see screenshot attached).

This seems to me as a bug as the http node can not access its own response data or do I need to add a for loop or add more http nodes?

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @fablan1

Instead of using the condition “When response is empty”

Try writing a condition that says “when data is empty”. Similar to this:


or this:

.

Also, make sure to write this URL expression when you already have an output available, so you can check if the expression is actually pulling data from the correct field:
image

:point_right: If my reply answers your question, please remember to mark it as a solution.

that’s not working. As I mentioned the “nextpage” value is available and the whole api call is working fine without the pagination option.
As soon I add the “pagination” option the whole request is not working anymore.
Seems to me that the pagination feature is not working correctly?

Pagination feature is working fine.
It’s a bit of a pain to set it up, but it works pretty well.

The solution I provided should have worked. Can you share the URL you are querying so I can test it further?

Yes, the pagination is working fine. I have tested the pagination with this api:

https://rickandmortyapi.com/api/character

And it is working without any issues.

I do not know why it is not working with my specific api endpoint maybe the pagination option can not handle a larger json response…

I made the workaround with an if else node and it is working without any issues…

I was working on something similar and just discovered the built-in counter $pageCount:

I believe this can solve your problem, so you don’t need the response formatted like this:

Give it a try! Here are the docs for further explanation.

1 Like

This is awesome, @mohamed3nan !
I didn’t know about the $pageCount function. Perfect :raised_hands:

Thank you both for your support. I still does not work with pagination method. Maybe it depends on the api itself.

If you share the complete URL of the API you are using, I could try it here.

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