Curl command in nodered

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

The command is curl -v --digest "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.

Use the EXEC node.

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?

you have bad feelings for the EXEC node? :wink:

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

1 Like

haha I would just rather keep the execution within nodered :slight_smile:

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

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

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]

No it is more complicated than that.

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

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

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

I’m typing this command:

curl -v --digest "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?

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.


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.

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

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?

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:

"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