# Setting http request url parmaters from msg.payload values

**URL:** <https://discourse.nodered.org/t/setting-http-request-url-parmaters-from-msg-payload-values/47279>\
**Category:** General\
**Created:** [17 June 2021 06:28 UTC](https://discourse.nodered.org/t/setting-http-request-url-parmaters-from-msg-payload-values/47279 "2021-06-17T06:28:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![laurialo](https://avatars.discourse-cdn.com/v4/letter/l/a8b319/32.png) [@laurialo](https://discourse.nodered.org/u/laurialo)\
**Post date:** [17 June 2021 06:28 UTC](https://discourse.nodered.org/t/setting-http-request-url-parmaters-from-msg-payload-values/47279/1 "2021-06-17T06:28:20Z")

</div>

Hello !

I created a following flow:

 ![Screenshot -my-flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/a/5af76ea4bbdf740e6aa556b7ef0e3d892b7587f8.png)

After the split node i use the change node where i want use the payload values as url parameters to make new API request. My change node:

 ![Screenshot-change-node2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/f/ffd329bef91bc3bbe63afb8fcbbef3803df64486.png)

My split node output debug console:  
 ![Screenshot split-node-output](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/14e17e1e7be70664bc141e6694402b9743412c75.png)

I have made some mistakes in setting url parameters because debug node after change node shows that i set the url parameter not correctly.  
 ![Screenshot-url-output](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c00f1cbcd47bb8fb3f209a146979b0130b3c40be.png)

How to set url parmetes correctly using the payload data to form correct url to make API requests.

The expected correct url example where is msg.paylod.id value in url:  
[https://localhost:4000/api/v1/clients/ee-dev:COM:10057662:ekukseireklient/tls-certificates](https://localhost:4000/api/v1/clients/ee-dev:COM:10057662:ekukseireklient/tls-certificates)

I would be very pleased if some one help what kind of mistake i have made in change node

Lauri-Alo Adamson

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [17 June 2021 07:51 UTC](https://discourse.nodered.org/t/setting-http-request-url-parmaters-from-msg-payload-values/47279/2 "2021-06-17T07:51:44Z")

</div>

> [@laurialo](#):
>
> ![Screenshot-url-output](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c00f1cbcd47bb8fb3f209a146979b0130b3c40be.png)

Does not work in a change node, you could paste it directly in the url field in the http request node

or in a change node use a JSONata expression eg.

```auto
[{"id":"d0885246.b8e748","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"\"https://localhost:4000/api/v1/clients/\" & payload.id & \"/tls-certificates\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":3080,"wires":[[]]}]

```

```auto
"https://localhost:4000/api/v1/clients/" & payload.id & "/tls-certificates"

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [17 June 2021 07:55 UTC](https://discourse.nodered.org/t/setting-http-request-url-parmaters-from-msg-payload-values/47279/3 "2021-06-17T07:55:03Z")

</div>

> [@laurialo](#):
>
> I have made some mistakes in setting url parameters because debug node after change node shows that i set the url parameter not correctly.  
> ![Screenshot-url-output](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c00f1cbcd47bb8fb3f209a146979b0130b3c40be.png)

The change node does not do mustache rendering. however, you can enter the URL with mustache syntax in the http request node directly.

Alternatively, you can use a function node or JSONata in a change node to set up `msg.url`.

Also...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/5598492365f79b0ce27c9f35e0935f6ea36e4577.png)  
↑ you have msg twice (this will end up `msg.msg.headers.Auth...`)

---

<div class="post-metadata">

**Author:** ![laurialo](https://avatars.discourse-cdn.com/v4/letter/l/a8b319/32.png) [@laurialo](https://discourse.nodered.org/u/laurialo)\
**Post date:** [17 June 2021 10:53 UTC](https://discourse.nodered.org/t/setting-http-request-url-parmaters-from-msg-payload-values/47279/4 "2021-06-17T10:53:12Z")

</div>

Sadly i'm new in this world and this jsonata is not very familiar to me - how can use it.  
This function node looks more understandable for example something like :

msg.url = '[https://localhost:4000/api/v1/clients/](https://localhost:4000/api/v1/clients/)\<msg.payload.id\>/tls-certificates'  
return msg;

Only trick how to insert set url with this msg.payload.id to form this url ?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [17 June 2021 11:06 UTC](https://discourse.nodered.org/t/setting-http-request-url-parmaters-from-msg-payload-values/47279/5 "2021-06-17T11:06:36Z")

</div>

`msg.url = "https://localhost:4000/api/v1/clients/" + msg.payload.id + "/tls-certificates";`  
in a function node. But you are using a change node so it would be simpler there and no extra node needed. But you may do it anyway you wish.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 August 2021 11:06 UTC](https://discourse.nodered.org/t/setting-http-request-url-parmaters-from-msg-payload-values/47279/6 "2021-08-16T11:06:37Z")

</div>

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