Page 1 of 1

The requested address '/zm/api/' was not found on this server.

Posted: Sat Nov 30, 2019 1:58 am
by simonpg
I have installed ZM 1.33.14 on clean Debian Buster.
All went well. I just upgraded to 1.33.15 and that went well.
My problem is with the API. I have attached a picture of what I get when I reference the URL: .../zm/api

When I reference the URL .../api/host/getVersion.json, I get:
{"success":false,"data":{"name":"Not Authenticated","message":"Not Authenticated","url":"\/zm\/api\/host\/getVersion.json","exception":{"class":"UnauthorizedException","code":401,"message":"Not Authenticated"}}}

This is my first time with ZoneMinder and it is remarkable!

Re: The requested address '/zm/api/' was not found on this server.

Posted: Sat Nov 30, 2019 3:50 am
by snake
That is expected for the path /zm/api, as I noticed that recently. Or at least, it appears to be setup right.

Try adding authentication to the http request.
e.g.

Code: Select all

curl -XPOST -d "user=admin&pass=password" http://<ipaddress>/zm/api/host/getVersion.json

Re: The requested address '/zm/api/' was not found on this server.

Posted: Sat Nov 30, 2019 4:17 am
by simonpg
Thank you for the timely reply! Alas, No Joy.

Re: The requested address '/zm/api/' was not found on this server.

Posted: Sat Nov 30, 2019 5:17 pm
by snake
What guide did you use to install? Is this on arm or x86/64?

Try the following per: https://wiki.zoneminder.com/Debian_8_64 ... ldid=14763
(This used to be required, I'm not sure if it is anymore...)

Code: Select all

chown -R www-data:www-data /usr/share/zoneminder/

Edit /etc/apache2/conf-enabled/zoneminder.conf
nano /etc/apache2/conf-enabled/zoneminder.conf
Add at the bottom:

<Directory /usr/share/zoneminder/www/api>
    AllowOverride All
</Directory>
If that doesn't work, see https://github.com/pliablepixels/zmNinj ... r-with-API

Re: The requested address '/zm/api/' was not found on this server.

Posted: Sat Nov 30, 2019 10:50 pm
by simonpg
"What guide did you use to install? Is this on arm or x86/64?"

Those are excellent questions! I'm sorry you had to ask them. The Guide:

https://wiki.zoneminder.com/Debian_10_B ... pro_Master

The architecture is x86_64.

I applied the suggested changes, and still No Joy.

Pliablepixels says, "if you find the page empty, your APIs/permissions have a problem." I did indeed find just JSON.

Re: The requested address '/zm/api/' was not found on this server.

Posted: Tue Dec 03, 2019 4:29 am
by simonpg
I turned off authentication (unchecked OPT_USE_AUTH), and I get Not Found instead of Not Authenticated for the same URL.

Re: The requested address '/zm/api/' was not found on this server.

Posted: Tue Dec 03, 2019 4:36 am
by simonpg
Some news: zm/api/host/getVersion.json returns {"version":"1.33.15","apiversion":"2.0"} with authentication off.

Re: The requested address '/zm/api/' was not found on this server.

Posted: Mon Dec 09, 2019 2:48 am
by rockedge
Turn the authentication back on.
Login into the ZM web console with the browser, open a new tab and use the URL http://your_ip/zm/api/host/getVersion.json and
you will see the return:

Code: Select all

{"version":"1.33.15","apiversion":"2.0"}
this return means the API is working as expected.

what your error message is telling us is that on your first attempt you were not logged in so there wasn't a proper login cookie created and the API returned "not authorized" which is a security feature. Once you had turned off the authorization the API did not need an authorization so it returned the proper response.

when you used /zm/api, this URL will return an error page because for better security the debug is turned off and this url is inaccessible from a browser and when you have the browser logged in to ZM and try zm/api/ you will receive an error notification, this is also for security reasons.

Re: The requested address '/zm/api/' was not found on this server.

Posted: Tue Mar 17, 2020 10:33 pm
by snake
snake wrote:
Sat Nov 30, 2019 3:50 am

Code: Select all

curl -XPOST -d "user=admin&pass=password" http://<ipaddress>/zm/api/host/getVersion.json
Double checked this today (1.32.3). The command above works, as long as you've installed ZM properly. There is no need to preface this command with a login.json. API commands can be called without logging in beforehand.

Likely, it did not work for original poster due to OPT_AUTH not enabled / user & pass setup, or otherwise installed incorrectly.