# HTTP Post command

**URL:** https://discourse.nodered.org/t/http-post-command/64083
**Category:** General
**Tags:** http-request
**Created:** [17 June 2022 16:57 UTC](https://discourse.nodered.org/t/http-post-command/64083 "2022-06-17T16:57:32Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Dasmonk3003](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dasmonk3003/32/63421_2.png) [@Dasmonk3003](https://discourse.nodered.org/u/Dasmonk3003)
#### Post date: [17 June 2022 16:57 UTC](https://discourse.nodered.org/t/http-post-command/64083/1 "2022-06-17T16:57:32Z")

</div>

Hey, my google powers is not enough and I havent really found a good explanation.

Can someone please tell me how I can send post request that looks like this?

curl -X POST -H "Content-Type: application/json" -d '{"percent":"+5"} [http://127.0.0.1:80/api/volume](http://127.0.0.1:80/api/volume)

Should I use function block first and set the it to JSON.

Thanks in advance.

---

<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 2022 18:05 UTC](https://discourse.nodered.org/t/http-post-command/64083/2 "2022-06-17T18:05:28Z")

</div>

You could use a change node, function node or a template node, The http request node will accept the json data in object form so setting `msg.payload .percent to` "+5" should work which every node you wish to use.  
e.g. using a inject node.

```auto
[{"id":"e3d6e970.e7768","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload.percent","v":"+5","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":3120,"wires":[["c62fdf0a.1924d8"]]},{"id":"c62fdf0a.1924d8","type":"http request","z":"bf9e1e33.030598","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://127.0.0.1:80/api/volume","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":3120,"wires":[["af8c089c.a6fbe8"]]},{"id":"af8c089c.a6fbe8","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":680,"y":3120,"wires":[]}]

```

[edit] added examples of function. change and template nodes.

```auto
[{"id":"e3d6e970.e7768","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"+5","payloadType":"str","x":130,"y":2920,"wires":[["ea6c0627.170ec","394d0823.2e2b1","3125445d.1e20e4"]]},{"id":"ea6c0627.170ec","type":"template","z":"bf9e1e33.030598","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"percent\": \"{{{payload}}}\"}","output":"json","x":300,"y":2920,"wires":[["af8c089c.a6fbe8"]]},{"id":"394d0823.2e2b1","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.percent","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":2980,"wires":[["af8c089c.a6fbe8"]]},{"id":"3125445d.1e20e4","type":"function","z":"bf9e1e33.030598","name":"","func":"msg.payload = {\"percent\": msg.payload};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":3040,"wires":[["af8c089c.a6fbe8"]]},{"id":"af8c089c.a6fbe8","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":720,"y":2920,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![Dasmonk3003](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dasmonk3003/32/63421_2.png) [@Dasmonk3003](https://discourse.nodered.org/u/Dasmonk3003)
#### Post date: [17 June 2022 20:25 UTC](https://discourse.nodered.org/t/http-post-command/64083/3 "2022-06-17T20:25:00Z")

</div>

Thanks it worked!  
Since I'm very new to this is it possibly get a example of it on the the other nodes tried to get it to work using the other ones but it was not functional.

---

<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 2022 23:20 UTC](https://discourse.nodered.org/t/http-post-command/64083/4 "2022-06-17T23:20:52Z")

</div>

> [@Dasmonk3003](#):
>
> Since I'm very new to this

You might benefit from the official videos. 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.

---

<div class="post-metadata">

### Author: ![Dasmonk3003](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dasmonk3003/32/63421_2.png) [@Dasmonk3003](https://discourse.nodered.org/u/Dasmonk3003)
#### Post date: [18 June 2022 07:12 UTC](https://discourse.nodered.org/t/http-post-command/64083/5 "2022-06-18T07:12:34Z")

</div>

Thanks, will do that.  
I think that will be fit me a lot!

---

<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: [2 July 2022 07:13 UTC](https://discourse.nodered.org/t/http-post-command/64083/6 "2022-07-02T07:13:25Z")

</div>

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