Fresh install of 1.34 into Ubuntu 18.04 LTS - API 401 Error

Forum for questions and support relating to the 1.34.x releases only.
Post Reply
kozmi92
Posts: 6
Joined: Thu Jul 04, 2019 1:59 pm

Fresh install of 1.34 into Ubuntu 18.04 LTS - API 401 Error

Post by kozmi92 »

Hi guys,
So far I used zoneminder 1.32 and decided to try the new version 1.34. I have created a new ubuntu server 18.04 LTS and have installed zoneminder 1.34 following the guidance at this url https://wiki.zoneminder.com/Ubuntu_Serv ... der_1.34.x
Everything went ok,but it looks that I cannot fix the API issue from 2 days trying many things.
If I open url http://zoneminder ip address/zm/api/ to web browser I get /zm/api Not Authenticated ( the url is open in a new tab after the successful login on another tab)
If I open http://zoneminder ip address/zm/api/host/getVersion.json I get this error:
"success": false,
"data": {
"name": "Not Authenticated",
"message": "Not Authenticated",
"url": "/zm/api/host/getVersion.json",
"exception": {
"class": "UnauthorizedException",
"code": 401,
"message": "Not Authenticated"

The same error with command line: curl -XPOST -d "user=user&pass=password" http://zoneminder ip address/zm/api/host/getVersion.json

The error.log shows these messages:

2020-02-03 21:01:53 Error: [UnauthorizedException] Not Authenticated
Request URL: /zm/api/host/getVersion.json
Stack Trace:
#0 /usr/share/zoneminder/www/api/lib/Cake/Event/CakeEventManager.php(243): AppController->beforeFilter(Object(CakeEvent))
#1 /usr/share/zoneminder/www/api/lib/Cake/Controller/Controller.php(677): CakeEventManager->dispatch(Object(CakeEvent))
#2 /usr/share/zoneminder/www/api/lib/Cake/Routing/Dispatcher.php(189): Controller->startupProcess()
#3 /usr/share/zoneminder/www/api/lib/Cake/Routing/Dispatcher.php(167): Dispatcher->_invoke(Object(HostController), Object(CakeRequest))
#4 /usr/share/zoneminder/www/api/app/webroot/index.php(107): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#5 {main}

I checked also the ownership of the files under /usr/share/zoneminder and everything looks ok as shown below.
ls -l /usr/share/zoneminder/
total 16
drwxr-xr-x 2 www-data www-data 12288 Feb 1 19:12 db
drwxr-xr-x 14 www-data www-data 4096 Feb 1 19:12 www

The command systemctl status zoneminder gives this :

zoneminder.service - ZoneMinder CCTV recording and surveillance system
Loaded: loaded (/lib/systemd/system/zoneminder.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-02-03 20:55:23 UTC; 25min ago
Process: 6843 ExecStop=/usr/bin/zmpkg.pl stop (code=exited, status=0/SUCCESS)
Process: 6857 ExecStart=/usr/bin/zmpkg.pl start (code=exited, status=0/SUCCESS)
Main PID: 6902 (zmdc.pl)
Tasks: 13 (limit: 1452)
CGroup: /system.slice/zoneminder.service
ââ6902 /usr/bin/perl -wT /usr/bin/zmdc.pl startup
ââ6934 /usr/bin/zmc -m 1
ââ6939 /usr/bin/zma -m 1
ââ6943 /usr/bin/zmc -m 2
ââ6947 /usr/bin/zma -m 2
ââ6951 /usr/bin/perl -wT /usr/bin/zmfilter.pl --filter_id=1 --daemon
ââ6956 /usr/bin/perl -wT /usr/bin/zmfilter.pl --filter_id=2 --daemon
ââ6962 /usr/bin/perl -wT /usr/bin/zmaudit.pl -c
ââ6969 /usr/bin/perl -wT /usr/bin/zmtrigger.pl
ââ6975 /usr/bin/perl -wT /usr/bin/zmwatch.pl
ââ6982 /usr/bin/perl -wT /usr/bin/zmupdate.pl -c
ââ6987 /usr/bin/perl -wT /usr/bin/zmtelemetry.pl
ââ6998 /usr/bin/perl -wT /usr/bin/zmstats.pl

Please someone give any suggestion how to resolve this ?

Thanks in advance for your kind support and time !
bbunge
Posts: 2934
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: Fresh install of 1.34 into Ubuntu 18.04 LTS - API 401 Error

Post by bbunge »

Did you enable the api for the user?
kozmi92
Posts: 6
Joined: Thu Jul 04, 2019 1:59 pm

Re: Fresh install of 1.34 into Ubuntu 18.04 LTS - API 401 Error

Post by kozmi92 »

Yes,API is enabled as shown in the attached printscreen,but I get 401 error for every url /zm/api/*

Thanks !
Attachments
API_printscreen.jpg
API_printscreen.jpg (83.73 KiB) Viewed 2045 times
bbunge
Posts: 2934
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: Fresh install of 1.34 into Ubuntu 18.04 LTS - API 401 Error

Post by bbunge »

Checked my production server running Bionic/Mariadb-server/NGINX/ZM 1.34.1

http://ip-addr/zm/api/host/getVersion.json
gives me
version "1.34.1"
apiversion "2.0"

Should be no different running Apache2 but I'll set up a test machine to be sure. Yes, I used the same instructions from the WIKI.
kozmi92
Posts: 6
Joined: Thu Jul 04, 2019 1:59 pm

Re: Fresh install of 1.34 into Ubuntu 18.04 LTS - API 401 Error

Post by kozmi92 »

Hello ,
I build it again from the scratch ,but now I have followed the guidance for MariaDB, Ngnix and now API tests are ok from the web interface.
When I try with zmninja(1.3) on my mobile I get the API Access Error and the log file shows the same error(listed below) I had when the API tests failed with my previous try with 1.34.
When I try with zmninja desktop it works fine.

Error: [UnauthorizedException] Not Authenticated
Request URL: /zm/api/host/getVersion.json?p=%2Fhost%2FgetVersion.json
Stack Trace:
#0 /usr/share/zoneminder/www/api/lib/Cake/Event/CakeEventManager.php(243): AppController->beforeFilter(Object(CakeEvent))
#1 /usr/share/zoneminder/www/api/lib/Cake/Controller/Controller.php(677): CakeEventManager->dispatch(Object(CakeEvent))
#2 /usr/share/zoneminder/www/api/lib/Cake/Routing/Dispatcher.php(189): Controller->startupProcess()
#3 /usr/share/zoneminder/www/api/lib/Cake/Routing/Dispatcher.php(167): Dispatcher->_invoke(Object(HostController), Object(CakeRequest))
#4 /usr/share/zoneminder/www/api/app/webroot/index.php(107): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#5 {main}
Post Reply