Page 1 of 2
unable to connect to API V1.34.22
Posted: Wed Nov 25, 2020 2:23 pm
by david1234
Hello,
I have a working zone-minder
record camera , see camera online on browser
but I can't login using API
when I run this command from the server itself I get "Not Found"
Code: Select all
pi@raspberrypi:~$ curl -XPOST -d "user=David&pass=MyRealPassword!" http://10.0.0.105/zm/api/host/login.json
{"name":"Not Found","message":"Not Found","url":"\/api\/zm\/api\/host\/login.json"}
when I enter to 10.0.0.105/zm from the browser I get the login page
everything is OK
what it could be ?
what else can I check ?
I did everything it said it the manual
I had the same problem on version 1.32.X - so I upgrade
Please advise
Thanks ,
Re: unable to connect to API V1.34.22
Posted: Wed Nov 25, 2020 8:14 pm
by Bluemax
Zoneminder on which distribution? It probably hasn't been set up properly by the maintainer. Usually it doesn't belong here but we will see how far we can get.
Re: unable to connect to API V1.34.22
Posted: Wed Nov 25, 2020 10:48 pm
by gbruneau
Make sure that OPT_USE_API is checked in the system options.
Re: unable to connect to API V1.34.22
Posted: Thu Nov 26, 2020 1:15 am
by burger
1. Install Zoneminder using officially recommended documentation (e.g.
https://wiki.zoneminder.com/Debian or
https://wiki.zoneminder.com/Ubuntu)
2. Follow API configuration on official zoneminder documentation (zoneminder.readthedocs.org)
3. curl -X POST -d "user=somename&pass=somepass"
http://serverip/zm/api/host/getVersion.json (from
https://wiki.zoneminder.com/API, but this is also in readthedocs as well)
At the moment, that is the proper way to setup API without any trouble. If you deviate from this (use FreeBSD, Docker, Alpine, etc)(follow instructions from your cousin's uncle's mother), you are on your own.
Re: unable to connect to API V1.34.22
Posted: Thu Nov 26, 2020 9:49 am
by david1234
I'm using Pi
I download pre-build image from here:
have ty to reach the the pesrson how put it - no success
have try to go everything it said in the manual - still get the same "not found' answer
OPT_USE_API is enabled
reboot the pi and try again
I have try with and without a password
none of them work
is there any way to print all the setting ? so maybe someone will see and poin at the problem ?
Thanks,
Re: unable to connect to API V1.34.22
Posted: Thu Nov 26, 2020 12:38 pm
by Bluemax
Please post the Apache/site-specific zoneminder.conf.
Re: unable to connect to API V1.34.22
Posted: Thu Nov 26, 2020 2:09 pm
by david1234
on the Pi I have the file here:
Code: Select all
/etc/apache2/sites-available/zoneminder.conf
is this the same?
this is the file:
Code: Select all
<VirtualHost *:80>
DocumentRoot /usr/share/zoneminder/www
ServerName zm
ErrorLog /var/log/apache2/error.log
# Order matters. This alias must come first.
Alias /zm/cache "/var/cache/zoneminder/cache"
Alias /cache "/var/cache/zoneminder/cache"
<Directory "/var/cache/zoneminder/cache">
Options -Indexes +FollowSymLinks
AllowOverride None
<IfModule mod_authz_core.c>
# Apache 2.4
Require all granted
</IfModule>
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/zoneminder/cgi-bin/
ScriptAlias /zm/cgi-bin/ /usr/lib/zoneminder/cgi-bin/
<Directory "/usr/lib/zoneminder/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
Alias /zm /usr/share/zoneminder/www
<Directory /usr/share/zoneminder/www>
php_flag register_globals off
Options +Indexes +FollowSymLinks
AllowOverride All
<IfModule mod_dir.c>
DirectoryIndex index.php
</IfModule>
#Satisfy Any
Order allow,deny
Allow from all
</Directory>
Alias /zm /usr/share/zoneminder/www
<Directory /usr/share/zoneminder/www>
php_flag register_globals off
Options +Indexes +FollowSymLinks
AllowOverride All
<IfModule mod_dir.c>
DirectoryIndex index.php
</IfModule>
#Satisfy Any
Order allow,deny
Allow from all
</Directory>
# For better visibility, the following directives have been migrated from the
# default .htaccess files included with the CakePHP project.
# Parameters not set here are inherited from the parent directive above.
<Directory "/usr/share/zoneminder/www/api">
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
RewriteBase /api
</Directory>
<Directory "/usr/share/zoneminder/www/api/app">
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
RewriteBase /api
</Directory>
<Directory "/usr/share/zoneminder/www/api/app/webroot">
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteBase /api
</Directory>
do you need anything else?
Thanks ,
Re: unable to connect to API V1.34.22
Posted: Thu Nov 26, 2020 2:51 pm
by Bluemax
Create a backup of the file and try this config.
https://github.com/ZoneMinder/zoneminde ... inder.conf
Reload the config or restart Apache.
Re: unable to connect to API V1.34.22
Posted: Thu Nov 26, 2020 3:25 pm
by david1234
I notice I have 2 files with the name in 2 places
Code: Select all
/etc/apache2/sites-enabled/zoneminder.conf
/etc/apache2/sites-available/zoneminder.conf
I cahgne both of them to what you post
then I reload the apache service by
Code: Select all
sudo systemctl restart apache2.service
chek to see if the everything is working using the browser - I can log on and see the cameras
but still when I use the curl commnd
Code: Select all
curl -X POST -d "user=David&pass=david" http://10.0.0.105/zm/api/host/getVersion.json
I get the same error:
Code: Select all
{"name":"Not Found","message":"Not Found","url":"\/api\/getVersion.json"}
nothing on
very strange no?
what else could it be ?
Thank you ,
Re: unable to connect to API V1.34.22
Posted: Thu Nov 26, 2020 6:14 pm
by Magic919
Those Apache configs are the exact same file. Sites-enabled should be a symlink to the sites-available config file. So you just edit the real one.
Re: unable to connect to API V1.34.22
Posted: Thu Nov 26, 2020 9:10 pm
by Bluemax
The most 'API not found' errors are probably due to bad rewrite rules. The server is pointing to the wrong path.
There should be an 'access.log' near the 'error.log' that should log all accesses. It might show you where the requests are going. Compare that to the webservers real path/folder structure. You could also check the browser 'console' (Firefox=F12) for something useful.
Re: unable to connect to API V1.34.22
Posted: Sun Nov 29, 2020 8:22 am
by david1234
when I look at the files they are empty
and las modify when I install the image
Code: Select all
ls -lst /var/log/apache2/access*
0 -rw-r----- 1 root adm 0 Jun 17 00:00 /var/log/apache2/access.log
4 -rw-r----- 1 root adm 623 Apr 29 2020 /var/log/apache2/access.log.1
and when I look at the file
Code: Select all
cat /var/log/apache2/access.log.1
192.168.9.119 - - [29/Apr/2020:17:10:30 +0100] "GET / HTTP/1.1" 200 3382 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko
) Chrome/70.0.3538.77 Safari/537.36"
192.168.9.119 - - [29/Apr/2020:17:10:30 +0100] "GET /icons/openlogo-75.png HTTP/1.1" 200 6042 "http://192.168.9.104/" "Mozilla/5.0 (X11; Linux x86_
64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
192.168.9.119 - - [29/Apr/2020:17:10:30 +0100] "GET /favicon.ico HTTP/1.1" 404 495 "http://192.168.9.104/" "Mozilla/5.0 (X11; Linux x86_64) AppleWe
bKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
which is even more strange becuse my home netwrok is 10.0.0.0/24 and not 192.168.9.0/24
Re: unable to connect to API V1.34.22
Posted: Sun Nov 29, 2020 8:50 am
by Magic919
Given those are months old, I’d assume Apache is not logging there. Do a find command and look for error and access and then hunt/grep through the results.
The .htaccess files are something that has caused me problems in the past.
Re: unable to connect to API V1.34.22
Posted: Sun Nov 29, 2020 9:23 am
by david1234
I found this
Code: Select all
ls -lstra /var/log/apache2/other_vhosts_access.log
4 -rw-r----- 1 root adm 113 Nov 29 11:18 /var/log/apache2/other_vhosts_access.log
pi@raspberrypi:~$ ls -lstra /var/log/apache2/other_vhosts_access*
4 -rw-r----- 1 root adm 781 Oct 20 20:45 /var/log/apache2/other_vhosts_access.log.14.gz
12 -rw-r----- 1 root adm 11681 Oct 21 17:59 /var/log/apache2/other_vhosts_access.log.13.gz
4 -rw-r----- 1 root adm 3022 Oct 29 17:30 /var/log/apache2/other_vhosts_access.log.12.gz
4 -rw-r----- 1 root adm 733 Oct 30 09:49 /var/log/apache2/other_vhosts_access.log.11.gz
4 -rw-r----- 1 root adm 2579 Nov 1 19:24 /var/log/apache2/other_vhosts_access.log.10.gz
4 -rw-r----- 1 root adm 344 Nov 3 17:07 /var/log/apache2/other_vhosts_access.log.9.gz
4 -rw-r----- 1 root adm 3152 Nov 4 17:08 /var/log/apache2/other_vhosts_access.log.8.gz
4 -rw-r----- 1 root adm 3493 Nov 5 18:17 /var/log/apache2/other_vhosts_access.log.7.gz
4 -rw-r----- 1 root adm 3155 Nov 8 16:31 /var/log/apache2/other_vhosts_access.log.6.gz
4 -rw-r----- 1 root adm 1822 Nov 10 17:58 /var/log/apache2/other_vhosts_access.log.5.gz
4 -rw-r----- 1 root adm 1979 Nov 17 17:06 /var/log/apache2/other_vhosts_access.log.4.gz
4 -rw-r----- 1 root adm 3149 Nov 18 17:26 /var/log/apache2/other_vhosts_access.log.3.gz
8 -rw-r----- 1 root adm 5486 Nov 25 16:20 /var/log/apache2/other_vhosts_access.log.2.gz
28 -rw-r----- 1 root adm 26917 Nov 26 17:26 /var/log/apache2/other_vhosts_access.log.1
then I run the curl command
Code: Select all
curl -X POST -d "user=David&pass=DavidPass" http://10.0.0.105/zm/api/host/getVersion.json
and saw a new file with today time stamp
Code: Select all
4 -rw-r----- 1 root adm 113 Nov 29 11:20 /var/log/apache2/other_vhosts_access.log
this is thew content of the file
Code: Select all
pi@raspberrypi:~$ cat /var/log/apache2/other_vhosts_access.log
zm:80 10.0.0.105 - - [29/Nov/2020:11:20:47 +0200] "POST /zm/api/host/getVersion.json HTTP/1.1" 404 252 "-" "curl/7.64.0
404 - not found , the same as the api response
what now can I do \ search ?
Thanks ,
Re: unable to connect to API V1.34.22
Posted: Sun Nov 29, 2020 12:08 pm
by Magic919
Can you test with authentication off?
Please check the filesystem where it's hosted to ensure it's free of .htaccess files. That's all the way from /usr/share/zoneminder/www/ to /usr/share/zoneminder/www/api/app/webroot/
Browse to
http://10.0.0.105/zm/api and see if you see Cake errors.