# Adding parameters of Api in HTTP Request Node

**URL:** https://discourse.nodered.org/t/adding-parameters-of-api-in-http-request-node/64205
**Category:** Hardware
**Tags:** http-request, function-node
**Created:** [21 June 2022 12:11 UTC](https://discourse.nodered.org/t/adding-parameters-of-api-in-http-request-node/64205 "2022-06-21T12:11:33Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Rahul\_98](https://avatars.discourse-cdn.com/v4/letter/r/ec9cab/32.png) [@Rahul\_98](https://discourse.nodered.org/u/Rahul_98)
#### Post date: [21 June 2022 12:11 UTC](https://discourse.nodered.org/t/adding-parameters-of-api-in-http-request-node/64205/1 "2022-06-21T12:11:33Z")

</div>

Below Flow is for calling API In that i have added the dateTime parameter i have written function but i am getting as error not able to call the parameters of API  
[  
{  
"id": "b34765c4163ec6fe",  
"type": "tab",  
"label": "Rest API",  
"disabled": false,  
"info": "",  
"env":   
},  
{  
"id": "1f20e2b49a5883ee",  
"type": "inject",  
"z": "b34765c4163ec6fe",  
"name": "Query Parameter",  
"props": [  
{  
"p": "payload"  
},  
{  
"p": "topic",  
"vt": "str"  
}  
],  
"repeat": "",  
"crontab": "",  
"once": false,  
"onceDelay": 0.1,  
"topic": " dateTime",  
"payload": "",  
"payloadType": "date",  
"x": 180,  
"y": 100,  
"wires": [  
[  
"dd3e4b46106047ba",  
"7dd86e710129a958"  
]  
]  
},  
{  
"id": "6e0c72d1e28b47dc",  
"type": "http request",  
"z": "b34765c4163ec6fe",  
"name": "",  
"method": "POST",  
"ret": "txt",  
"paytoqs": "ignore",  
"url": "[http://192.168.1.9:1301/api/OmronTagData/OmronTagdata?TagID=1&TagValue=\"+msg.payload+\"&dateTime=03-12-2021](http://192.168.1.9:1301/api/OmronTagData/OmronTagdata?TagID=1&TagValue=%5C%22+msg.payload+%5C%22&dateTime=03-12-2021) 13:00:00",  
"tls": "",  
"persist": true,  
"proxy": "",  
"authType": "bearer",  
"senderr": false,  
"x": 570,  
"y": 60,  
"wires": [  
[  
"5573231dec4d023d"  
]  
]  
},  
{  
"id": "5573231dec4d023d",  
"type": "debug",  
"z": "b34765c4163ec6fe",  
"name": "",  
"active": true,  
"tosidebar": true,  
"console": false,  
"tostatus": false,  
"complete": "false",  
"statusVal": "",  
"statusType": "auto",  
"x": 750,  
"y": 100,  
"wires":   
},  
{  
"id": "dd3e4b46106047ba",  
"type": "function",  
"z": "b34765c4163ec6fe",  
"name": "",  
"func": "msg.topic=new Date();\nreturn msg;",  
"outputs": 1,  
"noerr": 0,  
"initialize": "",  
"finalize": "",  
"libs": ,  
"x": 360,  
"y": 60,  
"wires": [  
[  
"6e0c72d1e28b47dc"  
]  
]  
},  
{  
"id": "160701bd3b119d62",  
"type": "function",  
"z": "b34765c4163ec6fe",  
"name": "",  
"func": "\nreturn msg;",  
"outputs": 1,  
"noerr": 0,  
"initialize": "",  
"finalize": "",  
"libs": ,  
"x": 520,  
"y": 140,  
"wires": [  
[  
"6e0c72d1e28b47dc"  
]  
]  
},  
{  
"id": "7dd86e710129a958",  
"type": "change",  
"z": "b34765c4163ec6fe",  
"name": "",  
"rules": [  
{  
"t": "set",  
"p": "payload",  
"pt": "msg",  
"to": "",  
"tot": "str"  
}  
],  
"action": "",  
"property": "",  
"from": "",  
"to": "",  
"reg": false,  
"x": 380,  
"y": 240,  
"wires": [  
[  
"160701bd3b119d62"  
]  
]  
}  
]

---

<div class="post-metadata">

### Author: ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)
#### Post date: [21 June 2022 12:20 UTC](https://discourse.nodered.org/t/adding-parameters-of-api-in-http-request-node/64205/2 "2022-06-21T12:20:50Z")

</div>

There are some examples of how to use the HTTP Request in the Node-red Cookbook

[https://cookbook.nodered.org/#http-requests](https://cookbook.nodered.org/#http-requests)

---

<div class="post-metadata">

### Author: ![Rahul\_98](https://avatars.discourse-cdn.com/v4/letter/r/ec9cab/32.png) [@Rahul\_98](https://discourse.nodered.org/u/Rahul_98)
#### Post date: [21 June 2022 13:00 UTC](https://discourse.nodered.org/t/adding-parameters-of-api-in-http-request-node/64205/3 "2022-06-21T13:00:18Z")

</div>

how to add the datetime parameter of API to make it dynamic

---

<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: [21 June 2022 13:00 UTC](https://discourse.nodered.org/t/adding-parameters-of-api-in-http-request-node/64205/4 "2022-06-21T13:00:18Z")

</div>

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<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: [21 June 2022 13:17 UTC](https://discourse.nodered.org/t/adding-parameters-of-api-in-http-request-node/64205/5 "2022-06-21T13:17:13Z")

</div>

You are clearly new to node-red so I will include some extra info for you at the end but first, your issues...

You cannot evaluate strings in a field...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/a/3a57c32f6b2f40359dfc9bd87d34ef23d41d4824.png)

You can however use mustache syntax as is detailed in the built in help...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/0/e03a43128108111cbf06800a1145757daead54c3.png)

e.g...  
`http://192.168.1.9:1301/api/OmronTagData/OmronTagdata?TagID={{TagID}}&TagValue="{{TagValue}}"&dateTime={{dateTime}}`

NOTE for this 👆 to work, you would need to set `msg.TagID`, `msg.TagValue` and `msg.dateTime` in the `msg` that goes to the HTTP-Request node

your current flow will cause the HTTP-Request to be executed twice

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/4/d42d67d81495483691b45e784a89a1dd4cf972a3.png)

A head start...

try importing this demo flow

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/e/9e8c56dbf4fa5ee6f8b1f6ea0f7d6c67fc8bfd29.png)

```auto
[{"id":"1f20e2b49a5883ee","type":"inject","z":"b34765c4163ec6fe","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":100,"wires":[["7dd86e710129a958"]]},{"id":"6e0c72d1e28b47dc","type":"http request","z":"b34765c4163ec6fe","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.9:1301/api/OmronTagData/OmronTagdata?TagID={{TagID}}&TagValue=\"{{TagValue}}\"&dateTime={{dateTime}}","tls":"","persist":true,"proxy":"","authType":"bearer","senderr":false,"x":570,"y":100,"wires":[["5573231dec4d023d"]]},{"id":"5573231dec4d023d","type":"debug","z":"b34765c4163ec6fe","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":100,"wires":[]},{"id":"7dd86e710129a958","type":"change","z":"b34765c4163ec6fe","name":"","rules":[{"t":"set","p":"TagID","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"TagValue","pt":"msg","to":"77","tot":"num"},{"t":"set","p":"dateTime","pt":"msg","to":"$moment($now()).format(\"YYYY-MM-DD HH:mm\")\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":100,"wires":[["d1850a61c7fa64d9","6e0c72d1e28b47dc"]]},{"id":"d1850a61c7fa64d9","type":"debug","z":"b34765c4163ec6fe","name":"Check msg.TagID and msg.dateTime ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":390,"y":160,"wires":[]}]

```

  

* * *

### Canned test / help for those new to node-red...

* * *

I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

* * *

See [this article in the cookbook](https://cookbook.nodered.org/basic/join-streams) for an example of how to join messages into one object.

* * *

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

* * *

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

### Author: ![Rahul\_98](https://avatars.discourse-cdn.com/v4/letter/r/ec9cab/32.png) [@Rahul\_98](https://discourse.nodered.org/u/Rahul_98)
#### Post date: [21 June 2022 19:05 UTC](https://discourse.nodered.org/t/adding-parameters-of-api-in-http-request-node/64205/6 "2022-06-21T19:05:00Z")

</div>

Thank you for helping me out ..its working now!

---

<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: [5 July 2022 19:05 UTC](https://discourse.nodered.org/t/adding-parameters-of-api-in-http-request-node/64205/7 "2022-07-05T19:05:07Z")

</div>

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