# Replicate this curl command in node red flow

**URL:** <https://discourse.nodered.org/t/replicate-this-curl-command-in-node-red-flow/27577>\
**Category:** General\
**Created:** [31 May 2020 15:55 UTC](https://discourse.nodered.org/t/replicate-this-curl-command-in-node-red-flow/27577 "2020-05-31T15:55:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![voodoobg](https://avatars.discourse-cdn.com/v4/letter/v/50afbb/32.png) [@voodoobg](https://discourse.nodered.org/u/voodoobg)\
**Post date:** [31 May 2020 15:55 UTC](https://discourse.nodered.org/t/replicate-this-curl-command-in-node-red-flow/27577/1 "2020-05-31T15:55:09Z")

</div>

I'm trying to send shut down command with curl to ReadyNAS NV+ v2 with this command:

```auto
curl -s -v -u user:pass -k "https://192.168.1.11/dbbroker" -H "Content-Type: application/x-www-form-urlencoded;" -H "X-Requested-With: XMLHttpRequest" --data "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xs:nml xmlns:xs=\"http://www.netgear.com/protocol/transaction/NMLSchema-0.9\" xmlns=\"urn:netgear:nas:readynasd\" src=\"dpv_1389313459000\" dst=\"nas\"><xs:transaction id=\"njl_id_725\"><xs:custom id=\"njl_id_724\" name=\"Halt\" resource-id=\"Shutdown\" resource-type=\"System\"><Shutdown halt=\"true\" fsck=\"false\"/></xs:custom></xs:transaction></xs:nml>"

```

It works from linux shell.  
Tried to implement it in Home Assistant with no luck.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [31 May 2020 16:19 UTC](https://discourse.nodered.org/t/replicate-this-curl-command-in-node-red-flow/27577/2 "2020-05-31T16:19:56Z")

</div>

I cannot imagine that this is the way to go, but if you want to proceed, you need to escape the double quotes (`"`) in the xml properly for node-red to parse it properly.

---

<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:** [31 May 2020 17:16 UTC](https://discourse.nodered.org/t/replicate-this-curl-command-in-node-red-flow/27577/3 "2020-05-31T17:16:56Z")

</div>

Have you tried a http request node? Set the data to the XML and add the headers.

---

<div class="post-metadata">

**Author:** ![voodoobg](https://avatars.discourse-cdn.com/v4/letter/v/50afbb/32.png) [@voodoobg](https://discourse.nodered.org/u/voodoobg)\
**Post date:** [31 May 2020 18:59 UTC](https://discourse.nodered.org/t/replicate-this-curl-command-in-node-red-flow/27577/4 "2020-05-31T18:59:41Z")

</div>

@bakman2 I have tried like this:

```auto
msg.headers = {
    'content-type': 'application/x-www-form-urlencoded',
    'X-Requested-With': 'XMLHttpRequest',
    'Authorization': 'Basic '+(new Buffer('user:pass')).toString('base64')
};
msg.payload = '<?xml version=\"1.0\" encoding=\"UTF-8\"?><xs:nml xmlns:xs=\"http://www.netgear.com/protocol/transaction/NMLSchema-0.9\" xmlns=\"urn:netgear:nas:readynasd\" src=\"dpv_1389313459000\" dst=\"nas\"><xs:transaction id=\"njl_id_725\"><xs:custom id=\"njl_id_724\" name=\"Halt\" resource-id=\"Shutdown\" resource-type=\"System\"><Shutdown halt=\"true\" fsck=\"false\"/></xs:custom></xs:transaction></xs:nml>';

return msg;

```

It's passing the xml with http request node, but since the server is https it doesn't work and i don't want to mess with rsa keys right now. Without the SSL it doesn't work with the code above.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [31 May 2020 19:33 UTC](https://discourse.nodered.org/t/replicate-this-curl-command-in-node-red-flow/27577/5 "2020-05-31T19:33:05Z")

</div>

@voodoobg please edit your post above (use the pencil icon) and [format your code as per this forum post](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506).

As you can see, the discourse forum changes the code that you posted making it difficult for others to help you.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [31 May 2020 19:41 UTC](https://discourse.nodered.org/t/replicate-this-curl-command-in-node-red-flow/27577/6 "2020-05-31T19:41:41Z")

</div>

> It works from linux shell.

Put it in a file and use the exec node ?

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [31 May 2020 19:49 UTC](https://discourse.nodered.org/t/replicate-this-curl-command-in-node-red-flow/27577/7 "2020-05-31T19:49:05Z")

</div>

This is how I use curl from node-RED to update Cloudflare with my IP address (albeit json - not xml)

```auto
[{"id":"eaa380d9.07f03","type":"template","z":"b3b413d1.05b1b","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":" curl -X PUT \"https://api.cloudflare.com/client/v4/zones/29aksjahkjsa7687364232bd/dns_records/52fceddb4004432ku3hi2323e\" \\\n -H \"X-Auth-Email: myemail@gmail.com\" \\\n -H \"X-Auth-Key: a5d2323iu2382dsh37y22j7c\" \\\n -H \"Content-Type: application/json\" \\\n --data '{\"type\":\"A\",\"name\":\"mydomain.co.uk\",\"content\":\"{{payload}}\",\"ttl\":1,\"proxied\":false}'","output":"str","x":360,"y":1465,"wires":[["e5236a1a.6e8fe8"]]},{"id":"e5236a1a.6e8fe8","type":"exec","z":"b3b413d1.05b1b","command":"","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":500,"y":1465,"wires":[[],[],[]]}]

```

![curl](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/f/7f4a27b3ed3fdfd41f28e7c5979b82501ee9d35a.jpeg)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [31 May 2020 20:51 UTC](https://discourse.nodered.org/t/replicate-this-curl-command-in-node-red-flow/27577/8 "2020-05-31T20:51:08Z")

</div>

Thanks Paul. I was just thinking I need to sort out for myself how to do that. That's saved me some effort working out how to do it.

---

<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:** [30 July 2020 20:51 UTC](https://discourse.nodered.org/t/replicate-this-curl-command-in-node-red-flow/27577/9 "2020-07-30T20:51:12Z")

</div>

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

---

<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:** [7 December 2020 11:15 UTC](https://discourse.nodered.org/t/replicate-this-curl-command-in-node-red-flow/27577/10 "2020-12-07T11:15:40Z")

</div>

Follow on thread / possible non exec solution posted here \>\> [Shutdown Netgear Readynas remotely](https://discourse.nodered.org/t/shutdown-netgear-readynas-remotely/37116)
