# How to insert two or more variable in http request

**URL:** <https://discourse.nodered.org/t/how-to-insert-two-or-more-variable-in-http-request/29476>\
**Category:** General\
**Created:** [4 July 2020 03:42 UTC](https://discourse.nodered.org/t/how-to-insert-two-or-more-variable-in-http-request/29476 "2020-07-04T03:42:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![apex](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@apex](https://discourse.nodered.org/u/apex)\
**Post date:** [4 July 2020 03:42 UTC](https://discourse.nodered.org/t/how-to-insert-two-or-more-variable-in-http-request/29476/1 "2020-07-04T03:42:29Z")

</div>

HI guy i am working on API which require 2 or more variable in the URL link  
something like this:

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

by now i only able to work on SIng le variable like {{{query}}} or {{{payload}}}  
but not more than one.  
My http get would be like this  
[http://api.heclouds.com/devices//datapoints](http://api.heclouds.com/devices//datapoints)? datastream\_id=3311\_0\_5851&start={{{starttime}}}&end={{{endtime}}}&limit={{{number}}}

Secondly, how can wait all the VARIABLE COME ALONG and then pass to the request at SAME time?

I would glad if anyone can help  
thanks

---

<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:** [4 July 2020 07:13 UTC](https://discourse.nodered.org/t/how-to-insert-two-or-more-variable-in-http-request/29476/2 "2020-07-04T07:13:19Z")

</div>

Here's an example. Hope it helps

```auto
[{"id":"8367f315.5045f8","type":"inject","z":"4484ee28.caa3c","name":"","topic":"startdate","payload":"124","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":360,"wires":[["5266085a.2568f8"]]},{"id":"51495b9b.dec9f4","type":"inject","z":"4484ee28.caa3c","name":"","topic":"enddate","payload":"123","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":420,"wires":[["5266085a.2568f8"]]},{"id":"5266085a.2568f8","type":"join","z":"4484ee28.caa3c","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":330,"y":380,"wires":[["b6f9a794.7feec8","5fcee44d.821854"]]},{"id":"5fcee44d.821854","type":"change","z":"4484ee28.caa3c","name":"","rules":[{"t":"set","p":"payload.datapoint","pt":"msg","to":"123456","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":440,"wires":[["6d7c0132.1dcd6"]]},{"id":"6d7c0132.1dcd6","type":"http request","z":"4484ee28.caa3c","name":"","method":"GET","ret":"txt","paytoqs":true,"url":"http://192.168.1.10:8765","tls":"","persist":false,"proxy":"","authType":"","x":660,"y":380,"wires":[["b6f9a794.7feec8"]]}]

```

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [4 July 2020 12:11 UTC](https://discourse.nodered.org/t/how-to-insert-two-or-more-variable-in-http-request/29476/3 "2020-07-04T12:11:59Z")

</div>

The answer is in the help. You can feed an object via the payload, tick the option in the request node and the object will be converted to parameters for you without needing to faff with a template.

---

<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:** [4 July 2020 13:32 UTC](https://discourse.nodered.org/t/how-to-insert-two-or-more-variable-in-http-request/29476/4 "2020-07-04T13:32:33Z")

</div>

The key point however is the different values are coming from different messages - they don't all appear in one message arriving at the request node.

This is what the example from @E1cid shows - using a join node to get the separate messages combined into one that can be passed to the request node.

---

<div class="post-metadata">

**Author:** ![apex](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@apex](https://discourse.nodered.org/u/apex)\
**Post date:** [7 July 2020 05:47 UTC](https://discourse.nodered.org/t/how-to-insert-two-or-more-variable-in-http-request/29476/5 "2020-07-07T05:47:48Z")

</div>

thanks.~ for your help~

---

<div class="post-metadata">

**Author:** ![apex](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@apex](https://discourse.nodered.org/u/apex)\
**Post date:** [7 July 2020 05:49 UTC](https://discourse.nodered.org/t/how-to-insert-two-or-more-variable-in-http-request/29476/6 "2020-07-07T05:49:10Z")

</div>

hi guy , i now worked ok , but what i do is to set the topic in each payload , and use the JOIN method mentioned by @E1cid.  
here is what i do here:

```auto
[{"id":"3fbad7f3.36a838","type":"ui_dropdown","z":"2f75621.f7baf9e","name":"","label":"Meter Device Id","tooltip":"","place":"Select option","group":"f6786336.72d818","order":2,"width":0,"height":0,"passthru":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":320,"y":500,"wires":[["6d405dbf.f2acac","18d22cc6.bfac9b"]]},{"id":"c8b62a85.b3b4b","type":"ui_date_picker","z":"2f75621.f7baf9e","name":"","label":"Start Date","group":"f6786336.72d818","order":3,"width":0,"height":0,"passthru":false,"topic":"start","x":100,"y":580,"wires":[["1734e401.2be6bc"]]},{"id":"1dad7b5b.9d119d","type":"string","z":"2f75621.f7baf9e","name":"strip Z","methods":[{"name":"strip","params":[{"type":"str","value":"Z"}]}],"prop":"end","propout":"payload","object":"msg","objectout":"msg","x":410,"y":660,"wires":[["58473606.eb95a"]]},{"id":"d32dac5d.cffe5","type":"debug","z":"2f75621.f7baf9e","name":"test 05","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":790,"y":740,"wires":[]},{"id":"5a929689.857ad8","type":"join","z":"2f75621.f7baf9e","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":790,"y":620,"wires":[["df79fb87.27602"]]},{"id":"ca4592bf.beeb9","type":"debug","z":"2f75621.f7baf9e","name":"tes03","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":810,"y":560,"wires":[]},{"id":"1734e401.2be6bc","type":"function","z":"2f75621.f7baf9e","name":"change string","func":"//var d = new Date(msg.payload);\n//var str = d.toDateString; //Wed Oct 23 2019\n//msg.payload = str;\n//return msg;\nmsg.topic = \"start\"\nvar d = new Date(msg.payload);\nmsg.payload = d.toISOString();\nmsg.start = msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":250,"y":580,"wires":[["d01a2fab.26079"]]},{"id":"d01a2fab.26079","type":"string","z":"2f75621.f7baf9e","name":"strip Z","methods":[{"name":"strip","params":[{"type":"str","value":"Z"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":410,"y":580,"wires":[["46876d8f.826254"]]},{"id":"46876d8f.826254","type":"function","z":"2f75621.f7baf9e","name":"set start query","func":"\nmsg.start = msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":620,"wires":[["ca4592bf.beeb9","5a929689.857ad8"]]},{"id":"d5b42919.14588","type":"function","z":"2f75621.f7baf9e","name":"change string","func":"//var d = new Date(msg.payload);\n//var str = d.toDateString; //Wed Oct 23 2019\n//msg.payload = str;\n//return msg;\nmsg.topic = \"end\"\nvar d = new Date(msg.payload);\nmsg.payload = d.toISOString();\nmsg.end = msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":250,"y":660,"wires":[["1dad7b5b.9d119d"]]},{"id":"58473606.eb95a","type":"function","z":"2f75621.f7baf9e","name":"set end query","func":"\nmsg.end = msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":720,"wires":[["5a929689.857ad8","d32dac5d.cffe5"]]},{"id":"f52c6ba2.04c0b","type":"ui_date_picker","z":"2f75621.f7baf9e","name":"","label":"End Date","group":"f6786336.72d818","order":4,"width":0,"height":0,"passthru":false,"topic":"end","x":100,"y":660,"wires":[["d5b42919.14588"]]},{"id":"18d22cc6.bfac9b","type":"function","z":"2f75621.f7baf9e","name":"set id query","func":"msg.topic = \"id\"\nmsg.id = msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":540,"wires":[["5a929689.857ad8"]]},{"id":"f6786336.72d818","type":"ui_group","z":"","name":"Watermeter usage","tab":"842ee1bc.352ac","order":1,"disp":true,"width":"6","collapse":false},{"id":"842ee1bc.352ac","type":"ui_tab","z":"","name":"20200704","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

```

---

<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 September 2020 05:49 UTC](https://discourse.nodered.org/t/how-to-insert-two-or-more-variable-in-http-request/29476/7 "2020-09-05T05:49:12Z")

</div>

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