Loop http Request problem with headers

Hello,

I have a strange behaviour when using the http node with a array of inputs.
My workflow works like this : I fetch a token at the beginning of the flow.
With this token I am able to launch another HTTP call to fetch a list of entities.
When I then try to launch another http request while parsing the list of entities, the header only is available for the first item in the loop. For the other calls, there is no value. Am I missing something ? I checked on my backend server and I see no token in the headers for all the other calls.



So the looping works well but the header does not work for every item of the loop
this is what the header expression looks like on all my HTTP request nodes

@babbel1005 change {{$node[“SET TOKEN”].json[“token”]}} to {{$item(0).$node[“SET TOKEN”].json[“token”]}}.

The set token node returns 1 item, but the Fetch subentities node receives more than one item. Since Fetch subentities is going to iterate over all input items and use the item index to resolve the expressions, you end up with something as follow:

Index Expression Final Value
0 {{$node[“SET TOKEN”].json[“token”]}} the token
1 {{$node[“SET TOKEN”].json[“token”]}} undefined
2 {{$node[“SET TOKEN”].json[“token”]}} undefined
i {{$node[“SET TOKEN”].json[“token”]}} undefined

Using $item(0), you tell the expression always to use the index 0, and as you can see in the table, the index 0 will always resolve to the token.

I hope that helps.

1 Like

Btw. you can find the documentation for $item() here:

1 Like

Perfect ! I understand how the node works now. Thank you very much, it works great now

1 Like