Can I make an expression to run just once in the HTTP node?

Describe the issue/error/question

After a lot of back and forth I managed to make my API pagination work. I finally had to add a code node to create a variable where I store the value, but ideally I wanted to streamline the flow and avoid the code node.

However, if I do that, the same expression in the HTTP node runs (I think) for every existing item, which triggers an 429 response of too many attempts. Is this expected behaviour? Or is there a way so it runs only once? The value I’m pulling is constant for the entire response, it doesn’t change per item (thanks to the first() ).

What is the error message (if any)?

{"status":"rejected","reason":{"message":"429 - \"<html>\\r\\n<head><title>429 Too Many Requests</title></head>\\r\\n<body>\\r\\n<center><h1>429 Too Many Requests</h1></center>\\r\\n<hr><center>nginx</center>\\r\\n</body>\\r\\n</html>\\r\\n\"","name":"Error","stack":"Error: 429 - \"<html>\\r\\n<head><title>429 Too Many Requests</title></head>\\r\\n<body>\\r\\n<center><h1>429 Too Many Requests</h1></center>\\r\\n<hr><center>nginx</center>\\r\\n</body>\\r\\n</html>\\r\\n\"\n    at createError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:269:11)\n    at IncomingMessage.emit (node:events:525:35)\n    at IncomingMessage.emit (node:domain:489:12)\n    at endReadableNT (node:internal/streams/readable:1358:12)\n    at processTicksAndRejections (node:internal/process/task_queues:83:21)"}}

Please share the workflow

You could probably use a set node to do it as well if you didn’t want the code node but that is how I would do it, The changes are the expression is not outputting what you expected it to in that node. Have you tried firing off the request to something like to see what is happening?

I also tried with the Set node, but it also runs for all the items.

I didn’t know I tried but I’m getting errors that it’s empty or something and not seeing the requests on the site (unlike if I just visit the URL, then they do appear). I’m just too noob for that. xD

You can probably just use $json.row_number +50, maybe that is what is going wrong.

No, that’d just iterate across all items. :S

I’m just looking for the first item’s value. Just that one. And not returned as many times as items are, but just once.

Do you mean not the expression using the first value, rather the node just executing one time and so outputting only the first item?

In this case that would be under the node settings the option “Execute Once”
Screenshot from 2023-03-17 16-12-16

1 Like

Omg you’re a star. I never noticed that option in there. It worked perfect. Thanks @jan

1 Like

Glad to hear. Have fun!

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