How do I link a HTTP Response (PUT) for login with a HTTP response (Get), such that credentials are used in the GET

flows.json (5.0 KB)
I did upgrade to 4.0.22, but still no success

You have two flows. In the top one, after the http request node you have a change node that sets global.cookies to the value of flow.cookie. But where is a value stored in flow.cookie? If flow.cookie has no value, global.cookie will end with no value.

In the second flow, your change node sets flow.cookie to the value of global.cookie. But where is a value stored in flow.cookie?

At some point in time, you have to store a value in flow.cookie or global.cookie.

Lets look at your top flow, if global.cookie has a value but flow.cookie does not, the change node will erase the content of global.cookie since there is nothing in flow.cookie.

What are you trying to accomplish with the flow and global variables?

1 Like

You are assuming it is the response cookies


What is circled in blue make the connection persist

Then store that and restore it like i've Shown

I did, it shows up in the second flow but it still in unauthorized. I think this goes back to the issue I provided in the link above. Node-red does not maintain state like postman

No it does not. You do. That's why we are telling you to store the necessary data and add it back in to the message on your 2nd request.

Postman is specifically designed for this task. Node-red can do this too but the node-red approach is too give you the building blocks that you put together.

If you can identify exactly what needs to go into the request headers it will work.

Inspect the heaters in postman, inspect the headers in your node-red GET request. Make them the same. it will work!

Found the issue, in postman, it adds the cookie (from the login) to the header. This is not supported in Node-red as I can not append. The change node will change the value if it exists, in which it does not. If you know a way around, let me know but so far nothing, will allow me to do it.

Of course it is supported. Use debug nodes and you will find the cookie. Store its value. Then add it to msg.headers in the GET request. It's what I've been saying the whole time.

I have tried to add it with change node, function node and with the http request node. I see in the debug from the change node and function node, but it is never append to the final request from the http request node.

Postman (note the blue circle is appended)


I perform the same with node-red and it does not append:

Please ignore the cookie Test, I was just using it to see if it would append

Instead of adding the cookie to the header, try it with msg.cookies = cookie.

Tried it as cookies as you suggested. It does not insert it into the header, similar to postman.

It will end up under the msg.res(ponse) cookies property.

Here is the Javascript version of what postman is doing:

image

To solve this problem with Node-red:


where on the first flow, the change node captures the set-cookie as follows:
image
and it is applied to the second flow, where the change applies it as follows:
image

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