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

Forum for questions and support relating to 1.33.x development only.
Locked
simonpg
Posts: 14
Joined: Fri Nov 29, 2019 8:55 pm

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

Post 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!
Attachments
Annotation 2019-11-29 173548.png
Annotation 2019-11-29 173548.png (71.92 KiB) Viewed 38975 times
User avatar
snake
Posts: 337
Joined: Sat May 21, 2016 2:20 am

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

Post 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
simonpg
Posts: 14
Joined: Fri Nov 29, 2019 8:55 pm

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

Post by simonpg »

Thank you for the timely reply! Alas, No Joy.
Attachments
Annotation 2019-11-29 201455.png
Annotation 2019-11-29 201455.png (40.27 KiB) Viewed 38963 times
User avatar
snake
Posts: 337
Joined: Sat May 21, 2016 2:20 am

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

Post 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
simonpg
Posts: 14
Joined: Fri Nov 29, 2019 8:55 pm

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

Post 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.
simonpg
Posts: 14
Joined: Fri Nov 29, 2019 8:55 pm

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

Post by simonpg »

I turned off authentication (unchecked OPT_USE_AUTH), and I get Not Found instead of Not Authenticated for the same URL.
simonpg
Posts: 14
Joined: Fri Nov 29, 2019 8:55 pm

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

Post by simonpg »

Some news: zm/api/host/getVersion.json returns {"version":"1.33.15","apiversion":"2.0"} with authentication off.
rockedge
Posts: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

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

Post 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.
User avatar
snake
Posts: 337
Joined: Sat May 21, 2016 2:20 am

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

Post 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.
Locked