Page 1 of 1

Control camera with the API

Posted: Sat Aug 05, 2023 8:26 pm
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

Re: Control camera with the API

Posted: Sun Aug 06, 2023 3:19 am
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)

Re: Control camera with the API

Posted: Mon Aug 14, 2023 11:12 am
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.

Re: Control camera with the API

Posted: Fri Aug 18, 2023 10:24 am
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