Loops only executing once

Hi,

I’m trying to make an API call to a GET endpoint that returns an array of objects. After that I want to iterate through the array and call an API with PUT method for each object.
I tried with the “For” loop but after iterate over the first element the flow either stops or gets stuck.
I change the flow to use “Repeat” and I’m getting the same behaviour. I iterates over the first item of the list and that’s it.

Can Someone give me a hand understanding why is not working? The AI didn’t help at all and broke my flow multiple times “trying to fix it”

Thanks!!!

I also tried storing the list in a variable and accessing it on each iteration

well u can try this enable “Wait for response” in your PUT block,
connect its Success → next of the Repeat block, and optionally add a small delay (100–200 ms) this will make Postman loop through all items properly i think.

1 Like

Hi @andresrv88

Welcome to the forums!

Storing the variable and accessing it every iteration is the correct solution you just need to pin the inline variables rather than have them on the canvas (right click on the body and index fields, swap block to get variable and it will be pinned by default)

We have documentation that goes over loops and pining variables here.

Let me know if you’re still running into problems. Also all your other variables on your final publish message block should be inline and as well.

1 Like

Hi! Thanks for the info and the tips. I just modified everything to be inline insted of on the canvas.
I read the documentation provided and analized my flow and it looks like all the blocks are inbetween the repeat and collect, so I don’t fully get why isn’t iterating.

The repeat “count” output is connected to 2 evaluates and the “Send” input for the PUT operation. Then the “Success” output of the put operation is connected to the “Start” input of the DELETE operation and the “Success” and “Fail” operation of the DELETE operation is attached to the input of the collect. So, as per documentation, those blocks should be inside the loop.

Am I getting something wrong here?

Also the PUT operation “Fail” output is connected to the collect also

Thanks!

Also, pinning the variables in the block made everything fail. This is because those variables are set by the environment I’m using.
If i set the variables by pinning them, the information from the env is not resolved correctly.
So had to rollback

hey can u go to Repeat Blovk and check whats inside the count input like is it {{someVariable}} or an expression?? and can u try running it with a static number for example “3” then re run the flow and let me know what the error is ??

Hi @andresrv88

You don’t need to fill out the values populated by the environment, just for the values you’re getting from the flow.

I would try disconnecting the failure ports for now as those might be causing issues cause it always receives the messageId value but only sometimes receives the errorResponse.