# Set value over http-request

**URL:** <https://discourse.nodered.org/t/set-value-over-http-request/17723>\
**Category:** General\
**Created:** [9 November 2019 21:17 UTC](https://discourse.nodered.org/t/set-value-over-http-request/17723 "2019-11-09T21:17:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![easyE4](https://avatars.discourse-cdn.com/v4/letter/e/a5b964/32.png) [@easyE4](https://discourse.nodered.org/u/easyE4)\
**Post date:** [9 November 2019 21:17 UTC](https://discourse.nodered.org/t/set-value-over-http-request/17723/1 "2019-11-09T21:17:20Z")

</div>

Hi guys,  
if I use this http-request behind an slider-node everything working fine.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/90b47c82d25f6dc0da8f3cd7012462a6b646fcbf.png)  
If I use a this this function-code to make the url it doesn't work.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/5587f01443e1ad22b2a9417d05099bf68bb7c481.png)  
I don't know why, because in other functions like this  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1320889091e4de9ad52a6b60b0da3102c3139454.png)  
it works as I expect.  
Where is my mistake?

Ralf

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [9 November 2019 21:31 UTC](https://discourse.nodered.org/t/set-value-over-http-request/17723/2 "2019-11-09T21:31:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![easyE4](https://avatars.discourse-cdn.com/v4/letter/e/a5b964/32.png) [@easyE4](https://discourse.nodered.org/u/easyE4)\
**Post date:** [9 November 2019 22:10 UTC](https://discourse.nodered.org/t/set-value-over-http-request/17723/3 "2019-11-09T22:10:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [9 November 2019 22:17 UTC](https://discourse.nodered.org/t/set-value-over-http-request/17723/4 "2019-11-09T22:17:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [9 November 2019 23:06 UTC](https://discourse.nodered.org/t/set-value-over-http-request/17723/5 "2019-11-09T23:06:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![easyE4](https://avatars.discourse-cdn.com/v4/letter/e/a5b964/32.png) [@easyE4](https://discourse.nodered.org/u/easyE4)\
**Post date:** [10 November 2019 07:48 UTC](https://discourse.nodered.org/t/set-value-over-http-request/17723/6 "2019-11-10T07:48:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [10 November 2019 08:08 UTC](https://discourse.nodered.org/t/set-value-over-http-request/17723/7 "2019-11-10T08:08:47Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![easyE4](https://avatars.discourse-cdn.com/v4/letter/e/a5b964/32.png) [@easyE4](https://discourse.nodered.org/u/easyE4)\
**Post date:** [10 November 2019 10:14 UTC](https://discourse.nodered.org/t/set-value-over-http-request/17723/8 "2019-11-10T10:14:29Z")

</div>

Thank you knolleary!  
Now it's runnung perfect 🙂
