Send value in a http-request

Hi erverybody,
in the dokumentation for the WebAPI of my controller I find this example:


What I want is to make the "val" variable, comming form a slider node.
Can someone help me with a small example. Please note, that I'm a beginner.

Thanks in advance!

in javascript you can use + to join variables

eg msg.payload = “the result is” + msg.result

Hi Ralf (@easyE4),
If I where you I would do it like this:

  • add a http-request node to your flow, where you can enter your url.
  • in the url replace "var" by "{{var}}" to have a Mustache syntax. See the cookbook for an example.
  • then the dashboard slider node should be wired (with some other nodes in between?) to the input of your http-request node to inject messages, whose data can be used for the Mustache variables.

Unfortunately I'm typing on my phone, so cannot give you an example flow...


I'm afraid I need a little more help. Maybe I did not put my question right.
I want to pass a setpoint to my PLC controller, which controls a frequency converter.
For a bit variable the http-request node looks like in the picture. There the value is fixed. Either 0 or 1.


Now I want to transfer a number generated by the slider in the dashboard, for example 0-100.

/ api / set / op? Op = MW & index = 12 & val = setpoint

So my question is, how can I fill "setpoint" with the value from the silider.


If you read the info panel for the http request node you will see that you can leave the URL field blank and can send the url in the message.

That way you can alter it in a function node or a template node

Back home ...

Suppose you do it like this:

[{"id":"8511c41b.bbe858","type":"ui_slider","z":"dc82a538.a81ba8","name":"","label":"slider","tooltip":"","group":"abd602cc.8182d","order":0,"width":0,"height":0,"passthru":true,"outs":"end","topic":"","min":0,"max":"100","step":1,"x":1220,"y":260,"wires":[["34c47b36.d234c4","79cfefc0.806ef"]]},{"id":"79cfefc0.806ef","type":"http request","z":"dc82a538.a81ba8","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"{{payload}}","tls":"","persist":false,"proxy":"","authType":"","x":1390,"y":260,"wires":[["a5f167ac.6b1ac8"]]},{"id":"a5f167ac.6b1ac8","type":"debug","z":"dc82a538.a81ba8","name":"Http request","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1560,"y":260,"wires":[]},{"id":"34c47b36.d234c4","type":"debug","z":"dc82a538.a81ba8","name":"Slider value","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1390,"y":320,"wires":[]},{"id":"abd602cc.8182d","type":"ui_group","z":"","name":"Default","tab":"92f88b13.45c2e8","disp":true,"width":"6","collapse":false},{"id":"92f88b13.45c2e8","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

  1. The slider generates values between 0 and 100, but not continiously (i.e. only on release) otherwise you will send too much http requests per second ...
  2. The slider output message will contain the slider value inside the msg.payload
  3. That message will trigger a http request. In the url we define that the value of var will be equal to the msg.payload of the input message (via a Mustache {{payload}} expression).
  4. For this test I send a http request to the postman-echo site, which returns the original http request as http response. That way you can see the http request that you have been send!
  5. The output message of the http-request node will contain the http response in the msg.payload. Since the postman-echo response is your original request, you can see that your url had been transformed to

So this way you can put your slider value into your http request...

Short demo:

Good luck with it!

Hi Bart,
thank you so much that you take so much time to help me!
I tried it with your suggestion. Unfortunately, my result looks a bit different and the variable is empty.

Where is my mistake?

You are welcome. When I was a beginner, others where helping me too ...
And those guys are still helping me now :wink:

Suppose your url is{{payload}}

The {{payload}} part of your URL will be replaced by the msg.payload of your input message. So if your slider is e.g. at value 13 I would expect your URL to become:

But of course I have no idea what the response of that request will be.
When you past the above URL in your browser, then you will see the result. As soon as that result is ok, I expect the http-request node to return exact the same response. But of course you need to make sure that the URL works also without Node-RED !!!

Hi Bart,
if I use this request and trigger a timestamp,
the word variable in my plc with the index 12 is set to the value 13.

Unfortunately, I find no way to change this value dynamically. I have been trying for hours now and can not find a solution.:worried:

I think it's time for a :beer: :smiley:

For you or for me ... :rofl:
Tomorrow - as soon as your hangover is gone - try the below flow.

[{"id":"28b18c7e.3ca1c4","type":"http request","z":"dc82a538.a81ba8","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"{{index}}&val={{payload}}","tls":"","persist":false,"proxy":"","authType":"","x":1100,"y":80,"wires":[["d06e4425.047898"]]}]


If I understand correctly, your Node-RED flow should set two variables in your URL: index and value. Correct? So your input message needs to contain those two variables, and it is up to you where you store them. For example I have used msg.index and msg.payload (but instead of payload you could also have used e.g. msg.value ....). The payload is the slider value, but I don't know where you want to get the index. That is again up to you ...

Anyway my URL contains those two variables (as Mustache expressions), so it wel get those two variables from the input message.

Cheers !!!

Hi Bart,
It works :grinning::grinning::grinning::grinning:
THANK YOU SO MUCH!! I am very, very grateful to you.

The next beer is on me :wink:

Good night and a nice sunday

1 Like

Glad to hear that it works. For the both of us ... :rofl:
Have a nice weekend!

1 Like