PUT API command

Hi People.

I'm using the HTTP request node to drive a PUT command for an integration, I have to send out Headers and data in the msg.payload. I want a button on the deashboard to trigger this event, if i put the data in the button's msg.payload it looks like it disappears by the time it reaches the PUT http request node.

curl -X 'PUT' \ 'https://xxxxxxxxxx.xx' \ -H 'accept: application/json' \ -H 'X-Session-Token: xyz' \ -H 'X-Api-Key: xyza' \ -H 'Content-Type: application/json' \ -d '{ "command": "DISARM", "ignoreProblems": true }'

What is the best way to attach msg.payload JSON data to it?
I tried to simply add msg.payload in the header list, but there is no selection for JSON and I'm sure it is not the right way.

This is my flow curently:

move the payload to another property (say msg.temp), after the button. Then execute the login request. Then move the msg.temp back to msg.payload prior to put request.

Hi Man,

thank you great idea, I will dig into it as sson as Im back in the office!

I'm getting somewhere but still not the finish line, and now I don"t understand what is happening.
This is my current flow:

In the Debug 11 I see the sessionToken , in the debugt10 I have the msg.payload that I set in the change node. But in debug 12 the sessioToken is not there anymore, and of course the final debug of the flow says "Session token not found"
This is my change node:

        "id": "1d8b16cb2e0b0449",
        "type": "change",
        "z": "f9f4bf7fdb1aa478",
        "name": "",
        "rules": [
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"command\":\"DISARM\",\"ignoreProblems\":true}",
                "tot": "json"
                "t": "set",
                "p": "payload.sessionToken",
                "pt": "msg",
                "to": "payload.sessionToken",
                "tot": "msg"
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 540,
        "y": 740,
        "wires": [

I don't understand why the session token disappears and not going in the ARM node for the PUT command.

Is there a way to save the session token in a file, and send the content of the file in as msg.payload.sessionToken?

When you set msg.payload to something, you wipe out its previous contents. You need to first

  • move payload.sessionToken to something else
  • set payload to the object
  • finally move the session token into the new payload object.

Try this:


Can't help much as all you have shared is one change node. Would be more helpful if you counld share the whole flow, then we could see the var usage. Obviously remove/alter any url or keys you don't want public.

Hi Man, this is working, Thank you. Im still at the bigginging of my jurney with Node-red and understanding what is going on. It was a big help thanks!

for some added the full flow as a second code, but I did't realizes it was not posted, propebly I deleted it or never saved the editit version??
@zenofmud 's idea was working, I tred a fep optin but it looks like I always overwrote the msg.payload or the msg.sessionToken.

Thanks guys! Appriciate it. I hope soon I will learn enough to be able to help out others.

1 Like

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