Set value over http-request

Hi guys,
if I use this http-request behind an slider-node everything working fine.
image
If I use a this this function-code to make the url it doesn't work.
image
I don't know why, because in other functions like this
image
it works as I expect.
Where is my mistake?

Ralf

Feed the output of the function node into a debug node which is set to show the complete message. Then look at what you are getting to see where the problem lies.

In the debug node, I can not see any information that helps me to solve the problem.

Don't think that the & are allowed like that in the url, you have to replace them with &

The problem is the msg.url you are constructing contains {payload}. That syntax only works when you enter it the URL field of node.

If you pass in msg.url then it uses it exactly as you provide it.

So change your function to include msg.payload in the string directly. I would show you what I mean, but I can't copy and paste your code from a screenshot.

Hi knolleary,
it would be great, if you can show me what you mean. So here my code.

var url ="http://";
Ip_address=;
Api_key=;
Ip_address = global.get('ip');
Api_key=global.get('api')
url=url.concat(Ip_address)
url=url.concat("/api/set/op?op=MW&index=12&val={{payload}}")
msg.url=url;
msg.headers = { Authorization: "Bearer "+ Api_key};
return msg

Thank you
Ralf

url=url + "/api/set/op?op=MW&index=12&val=" + msg.payload;
1 Like

Thank you knolleary!
Now it's runnung perfect :slight_smile: