I'm trying to send shut down command with curl to ReadyNAS NV+ v2 with this command:
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.
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.
Have you tried a http request node? Set the data to the XML and add the headers.
@bakman2 I have tried like this:
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.
@voodoobg please edit your post above (use the pencil icon) and format your code as per this forum post .
As you can see, the discourse forum changes the code that you posted making it difficult for others to help you.
It works from linux shell.
Put it in a file and use the exec node ?
This is how I use curl from node-RED to update Cloudflare with my IP address (albeit json - not xml)
[{"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":[[],[],[]]}]
Colin
31 May 2020 20:51
8
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.
1 Like
system
Closed
30 July 2020 20:51
9
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
Follow on thread / possible non exec solution posted here >> Shutdown Netgear Readynas remotely