I have a function node that provides an IP address to msg.payload. And this IP address is never the same. From the function node that supplies the IP address, it goes to an HTTP Request node. The HTTP request node then has to do something to the specified IP address. Inside my HTTP Request node, I have used this
http://+{{msg.payload}}+/control?cmd=GPIO,1,1
Because msg.payload is always different.
It doesn't work.
Am i doing something wrong with this?
+{{msg.payload}}+
because i have tried the following:
{{msg.payload}}
{{{msg.payload}}}
+{{msg.payload}}+
And none of them seem to work.
Please help.
From the Info sidebar for the http-request
node:
When configured within the node, the URL property can contain mustache-style tags. These allow the url to be constructed using values of the incoming message. For example, if the url is set to example.com/{{{topic}}}, it will have the value of msg.topic automatically inserted. Using {{{...}}} prevents mustache from escaping characters like / & etc
To include the msg.payload
in the url using the mustache syntax you would do the following:
http://{{payload}}/control?cmd=GPIO,1,1
Or you can leave the URL field blank and pass the whole URL in via the msg object with the key url
.
e.g. in say a function
node before the http-request
node set the following:
msg.url = "http://" + msg.payload + "/control?cmd=GPIO,1,1";
return msg;