# Basic Http request + cURL parameters

**URL:** <https://discourse.nodered.org/t/basic-http-request-curl-parameters/78501>\
**Category:** General\
**Created:** [17 May 2023 16:52 UTC](https://discourse.nodered.org/t/basic-http-request-curl-parameters/78501 "2023-05-17T16:52:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vongomben](https://avatars.discourse-cdn.com/v4/letter/v/a4c791/32.png) [@vongomben](https://discourse.nodered.org/u/vongomben)\
**Post date:** [17 May 2023 16:52 UTC](https://discourse.nodered.org/t/basic-http-request-curl-parameters/78501/1 "2023-05-17T16:52:53Z")

</div>

Hi!

I'm stuck in a process of accessing / making requests a testing woocommerce instance.  
This allowed me to crash on a old problem I've had in node-red: how to pass cURL parameters in a call.

How do I - say - [create a product](https://woocommerce.github.io/woocommerce-rest-api-docs/?shell#create-a-product)?

While I'm able to authenticate and retrive the list of products, I don't understand how to pass parameters in the call, to be specific, the `-d` specified in the call with the json.

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

my flow:

```auto
[{"id":"153f50acda5fe0d6","type":"http request","z":"8dbd31e890d4295d","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"{{{site}}}{{{endPoint}}}","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"basic","senderr":false,"headers":[],"x":447.17896270751953,"y":905.0554389953613,"wires":[["b044df9340de714e"]]},{"id":"b044df9340de714e","type":"debug","z":"8dbd31e890d4295d","name":"","active":true,"console":"false","complete":"payload","x":578.0992164611816,"y":848.545488357544,"wires":[]},{"id":"ffb38a52daba1dd0","type":"change","z":"8dbd31e890d4295d","name":"Set Headers","rules":[{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"headers.content-type","pt":"msg","to":"application/json","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":312.0994644165039,"y":850.3637266159058,"wires":[["153f50acda5fe0d6"]]},{"id":"1730582a0669739a","type":"inject","z":"8dbd31e890d4295d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"endPoint","v":"/wp-json/wc/v3/products","vt":"str"},{"p":"site","v":"mySite.com","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"name\":\"Premium Quality\",\"type\":\"simple\",\"regular_price\":\"21.99\",\"description\":\"Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.\",\"short_description\":\"Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\",\"categories\":[{\"id\":9},{\"id\":14}],\"images\":[{\"src\":\"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg\"},{\"src\":\"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg\"}]}","payloadType":"json","x":193.09944915771484,"y":910.3636865615845,"wires":[["ffb38a52daba1dd0"]]},{"id":"d018848cf10db5ef","type":"comment","z":"8dbd31e890d4295d","name":"Create a Product in Woocommerce","info":"","x":369.19036865234375,"y":786.4247627258301,"wires":[]}]

```

---

<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 May 2023 17:41 UTC](https://discourse.nodered.org/t/basic-http-request-curl-parameters/78501/2 "2023-05-17T17:41:21Z")

</div>

The `-d` is the data and would be passed to the http request node in `msg.payload` and the request should be a `POST`.  
Something like this

```auto
[{"id":"ffb38a52daba1dd0","type":"change","z":"b9860b4b9de8c8da","name":"Set Headers","rules":[{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"headers.content-type","pt":"msg","to":"application/json","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":314.9205017089844,"y":2685.3082876205444,"wires":[["153f50acda5fe0d6"]]},{"id":"1730582a0669739a","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"payload"},{"p":"payload"},{"p":"endPoint","v":"/wp-json/wc/v3/products","vt":"str"},{"p":"site","v":"mySite.com","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \"name\": \"Premium Quality\", \"type\": \"simple\", \"regular_price\": \"21.99\", \"description\": \"Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.\", \"short_description\": \"Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\", \"categories\": [{ \"id\": 9 }, { \"id\": 14 }], \"images\": [{ \"src\": \"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg\" }, { \"src\": \"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg\" }] }","payloadType":"json","x":195.9204864501953,"y":2745.308247566223,"wires":[["ffb38a52daba1dd0"]]},{"id":"153f50acda5fe0d6","type":"http request","z":"b9860b4b9de8c8da","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"{{{site}}}{{{endPoint}}}","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"basic","senderr":false,"headers":[],"credentials":{},"x":450,"y":2740,"wires":[["b044df9340de714e"]]},{"id":"b044df9340de714e","type":"debug","z":"b9860b4b9de8c8da","name":"","active":true,"console":"false","complete":"payload","x":580.9202537536621,"y":2683.4900493621826,"wires":[]}]

```

Untested.  
[edit] fixed miss paste.

---

<div class="post-metadata">

**Author:** ![vongomben](https://avatars.discourse-cdn.com/v4/letter/v/a4c791/32.png) [@vongomben](https://discourse.nodered.org/u/vongomben)\
**Post date:** [17 May 2023 19:46 UTC](https://discourse.nodered.org/t/basic-http-request-curl-parameters/78501/3 "2023-05-17T19:46:28Z")

</div>

thanks.  
I've imported your flow, and I see two payloads in the inject node.

> The `-d` is the data and would be passed to the http request node in `msg.payload` and the request should be a `POST` .

So the `-d` in the cURL is basically the JSON I'm sending for creating a new product?

---

<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 May 2023 20:03 UTC](https://discourse.nodered.org/t/basic-http-request-curl-parameters/78501/4 "2023-05-17T20:03:34Z")

</div>

> [@vongomben](#):
>
> I've imported your flow, and I see two payloads in the inject node.

That will teach me to try to multi task.

> [@vongomben](#):
>
> So the `-d` in the cURL is basically the JSON I'm sending for creating a new product?

Yes according to my limited read of the api.

---

<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 July 2023 20:04 UTC](https://discourse.nodered.org/t/basic-http-request-curl-parameters/78501/5 "2023-07-16T20:04:19Z")

</div>

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