Control camera with the API

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
dinosaure
Posts: 7
Joined: Mon Jul 24, 2023 9:15 am

Control camera with the API

Post by dinosaure »

Hi all,

I'm using 1.36.33 version of zoneminder on debian bookworm.

I'm trying to use API zoneminder.

My nginx configuration have this lines for API.
Is it correct ?

Code: Select all

location /zm/api {
         rewrite ^/zm/api(.+)$ /zm/api/app/webroot/index.php?p=$1 last;
}
I check all available camera with this command.

Code: Select all

curl -d "username=user&password=mypassword&action=login&view=console" -c cookies.txt http://mydomain/zm/api/monitors.json
And i try to change the name of one camera.

Code: Select all

curl -XPUT http://zone.freewind.fr/zm/api/monitors/8.json -d "Monitor[Name]=test1"
After checking with monitors.json, the name doesn't changed and nginx give the following result.

Code: Select all

"PUT /zm/api/monitors/X.json HTTP/1.0" 200 8474 "-" "curl/7.88.1"
I'm using this documentation. It's a good one ?
https://sgzoneminder.readthedocs.io/en/ ... n/api.html

Have you an idea about this ?

Thanks a lot
User avatar
burger
Posts: 393
Joined: Mon May 11, 2020 4:32 pm

Re: Control camera with the API

Post by burger »

See https://wiki.zoneminder.com/API

Make sure nginx is configured properly with https://wiki.zoneminder.com/Debian_11_B ... der_1.36.x which should be close enough for bookworm (although no guarantees)
fastest way to test streams:
ffmpeg -i rtsp://<user>:<pass>@<ipaddress>:554/path ./output.mp4 (if terminal only)
ffplay rtsp://<user>:<pass>@<ipaddress>:554/path (gui)
find paths on ispydb or in zm hcl

If you are new to security software, read:
https://wiki.zoneminder.com/Dummies_Guide
dinosaure
Posts: 7
Joined: Mon Jul 24, 2023 9:15 am

Re: Control camera with the API

Post by dinosaure »

Thanks for your feedback.

I have tried to use the nginx configuration what you said.

When i try to acces to index.php, i have this nginx error log.

Code: Select all

[error] 86425#86425: *17 directory index of "/usr/share/zoneminder/www/" is forbidden, client: XX.XX.XX.XX, server: XX.XX.XX.XX, request: "GET / HTTP/1.0", host: "XX.XX.XX.XX".
Why ? I don't know ! Because of a proxy_pass ? The user who use this directory is ? www-data ? Thanks a lot.
dinosaure
Posts: 7
Joined: Mon Jul 24, 2023 9:15 am

Re: Control camera with the API

Post by dinosaure »

I have a good nginx configuration.

Now, i try this command. I delete /zm of the URL path.

Code: Select all

curl -d "username=user&password=mypassword&action=login&view=console" -c cookies.txt http://mydomain/api/monitors.json
I have this log.

Code: Select all

{"message":{"Name":["Monitor Name must be specified for creation","Monitor Name must be specified for creation"]}}
So i'm not authenticated, after i try this command.

Code: Select all

curl http://server/api/host/getVersion.json
I have this log.

Code: Select all

{"success":false,"data":{"name":"Not Authenticated","message":"Not Authenticated","url":"\/api\/host\/getVersion.json?p=%2Fhost%2FgetVersion.json","exception":{"class":"UnauthorizedException","code":401,"message":"Not Authenticated"}}}.
Have you an idea ? Thanks a lot
Post Reply