# Curl command in nodered

**URL:** <https://discourse.nodered.org/t/curl-command-in-nodered/85393>\
**Category:** General\
**Created:** [10 February 2024 09:13 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393 "2024-02-10T09:13:26Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [10 February 2024 09:13 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/1 "2024-02-10T09:13:26Z")

</div>

I am using a curl command in cmd prompt to get events from my NVR.

The command is curl -v --digest "[http://username](http://username):password@ip\_address/cgi-bin/eventManager xxx"

When I execute the command using curl, I get a response from the NVR everytime motion is detected.

How do I replicate this in nodered? I tried the http input node using GET and the URL above, but I'm receiving no events from it.

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [10 February 2024 09:33 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/2 "2024-02-10T09:33:41Z")

</div>

Use the EXEC node.

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [10 February 2024 09:34 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/3 "2024-02-10T09:34:13Z")

</div>

Thanks for the reply - do I really need to use the exec node? I would prefer not. Is there a way to do it with the existing http nodes?

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [10 February 2024 09:35 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/4 "2024-02-10T09:35:10Z")

</div>

you have bad feelings for the EXEC node? 😉

---

<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:** [10 February 2024 09:36 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/5 "2024-02-10T09:36:34Z")

</div>

Use the http request node, not the http in node.  
check `use authorization` and select type `digest`  
add you username and password.

What NVR are you using? as node-red-contrib-hikvision-ultimate works with some non hikvision NVR

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [10 February 2024 09:36 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/6 "2024-02-10T09:36:42Z")

</div>

haha I would just rather keep the execution within nodered 🙂

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [10 February 2024 09:38 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/7 "2024-02-10T09:38:40Z")

</div>

> [@E1cid](#):
>
> Use the http request node, not the http in node.  
> check `use authorization` and select type `digest`  
> add you username and pass word.

Thanks - do you have to inject into the http request node for it to work?

---

<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:** [10 February 2024 09:40 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/8 "2024-02-10T09:40:21Z")

</div>

Yes to send the request a message must be sent to the node(of any type)

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [10 February 2024 09:41 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/9 "2024-02-10T09:41:21Z")

</div>

so inject a timestamp, enable keep connection alive, and it should continue to listen for these events that the NVR is posting?

I tried this and I get a non-http Transport requested? the full URL is http://ip\_addr:port/cgi-bin/eventManager.cgi?action=attach&channel=0&codes=[VideoMotion]

---

<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:** [10 February 2024 09:45 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/10 "2024-02-10T09:45:14Z")

</div>

No it is more complicated than that.

What NVR is this? how old? does it support ISAPI?

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [10 February 2024 09:47 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/11 "2024-02-10T09:47:44Z")

</div>

I don't know what ISAPI is.. but surely I can just replicate what I am doing in CMD prompt here?

It is a Dahua NVR 5208 8 port

---

<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:** [10 February 2024 10:04 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/12 "2024-02-10T10:04:37Z")

</div>

And what are you doing in command promp? use exec as suggested earlier if you want to command prompt.  
ISAPI is internet security application processing interface, basically an api for NVR's and other security stuff. If your device supports it (my NVR has a check box in config to enable isapi) you can then possibly use node-red-contrib-hikvision-ultimate.  
maybe these may help also  
[https://flows.nodered.org/search?term=Dahua](https://flows.nodered.org/search?term=Dahua)

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [10 February 2024 10:36 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/13 "2024-02-10T10:36:44Z")

</div>

I’m typing this command:

curl -v --digest "[http://username](http://username):password@ip\_address/cgi-bin/eventManager xxx"

Then every time motion is detected the nvr spits out a response in command prompt.

Maybe I’ll just use the exec node if there’s no way to use nodered nodes?

---

<div class="post-metadata">

**Author:** ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)\
**Post date:** [10 February 2024 10:45 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/14 "2024-02-10T10:45:02Z")

</div>

I use an HTTP Request Node to talk to a Router that I was given a Curl commend for. I went through some pain, but was ably helped by people on the Forum [in this thread](https://discourse.nodered.org/t/translation-of-curl-command-to-http-request/52101).

HTH

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [10 February 2024 20:29 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/15 "2024-02-10T20:29:06Z")

</div>

Thanks - but I think I will try the exec node.

With the exec node, I've tried the exact command that I use in CMD prompt. I can see the process is running but I get no output from the exec node when I walk in front of the camera (i.e. motion detected). The output comes when I kill the process.

I then tried spawn mode, but the only output I am getting is from port 2, however it's just a bunch of random numbers all the time every 1s. No output from any other ports.

Where as if the curl command is running in CMD prompt, I get an output everytime motion is detected.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [10 February 2024 21:27 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/16 "2024-02-10T21:27:44Z")

</div>

For longer running processes like this you may need to use the node-red-node-daemon node instead of exec.

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [10 February 2024 22:47 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/17 "2024-02-10T22:47:35Z")

</div>

Thanks for the reply - I tried the daemon node with the curl command above in the "Command" field. I sent a msg.start and it returns a payload of -2 on the 3rd output then "STOPPED" appears under the node.

What does payload = -2 mean?

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [12 February 2024 02:47 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/18 "2024-02-12T02:47:59Z")

</div>

Ok so I got the curl comamnd to work with node-red-node-daemon.

When the node first initiates, I can see the print out from the curl command, but only on port 2. Shouldn't this be outputting on Port 1? Executing the command in terminal displays this information on the terminal itself, which comes from Std Out. I thought Port 2 is used for Std Error?

Anyways - instead of returning the msg content, I am getting:

"{ [319 bytes data]"

in the debug window.

The output from the command should look like this:

Code=VideoMotion;action=Start;index=4;data={  
"Id" : [0],  
"LocaleTime" : "2024-02-12 11:37:14",  
"MachineName" : "XXX",  
"Name" : "YYY",  
"RegionName" : ["Region1"],  
"SmartMotionEnable" : false,  
"UTC" : 1707701834.0  
}

Which is what I see in the terminal window when executing the command manually

---

<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:** [12 May 2024 02:48 UTC](https://discourse.nodered.org/t/curl-command-in-nodered/85393/19 "2024-05-12T02:48:51Z")

</div>

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