API seems to be working but monitors.json is missing

Forum for questions and support relating to the 1.29.x releases only.
Locked
misterandres
Posts: 6
Joined: Tue Jul 19, 2016 2:22 am

API seems to be working but monitors.json is missing

Post by misterandres »

Hello,
I am following the article on http://zoneminder.readthedocs.io/en/stable/api.html. First step, curl login, it is a total success. The cookie.txt is created on my local directory and the returned page is exactly what I got when I login to the console.
The problem comes with the second command suggested by the article:
curl -b cookies.txt http://yourzmip/zm/api/monitors.json
Among other stuff (the html scaffold of the page) I am getting this in the output:
The requested URL was not found on this server.

And to make things worse, monitors.json does not exist in my server (updatedb/locate)

CakePHP is version 2.5 (bundle with the 1.29) and it seems to be working nicely (permissions are fixed, database.php edited, etc, etc). When I try http://localhost/zm/api I am getting the expected page, with a lot of links and some query statements at the bottom of the page. Just in case I am adding it here:

Image


Thank you very much,
misterandres
Posts: 6
Joined: Tue Jul 19, 2016 2:22 am

Re: API seems to be working but monitors.json is missing

Post by misterandres »

I've downloaded the src file from the release-1.29.0 branch, and there is no monitors.json there. Actually I only find composer.json and installed.json. It makes me think that I am missing some important part on the API installation. Can someboy shed some light here?
Thank you!
SteveGilvarry
Posts: 494
Joined: Sun Jun 29, 2014 1:12 pm
Location: Melbourne, AU

Re: API seems to be working but monitors.json is missing

Post by SteveGilvarry »

Yes magic of api is it takes the file name and does stuff, no actual files.
http://hostname_or_ip/zm/api/ so this in browser gives you all green, except for one yellow about debug kit.
Production Zoneminder 1.37.x (Living dangerously)
Random Selection of Cameras (Dahua and Hikvision)
misterandres
Posts: 6
Joined: Tue Jul 19, 2016 2:22 am

Re: API seems to be working but monitors.json is missing

Post by misterandres »

Thank you very much SteveGilvarry, Once that you told me that they were generated on the fly I was able to rest the case of searching for the missing file.
Solution: I had to follow the rewrite_mod guide in the CakePHP website. The .htaccess file inside api/web/root had different RewriteRule to what they suggested (CakePHP):

Original: RewriteRule ^ index.php [L]

From CakePHP: RewriteRule ^(.*)$ index.php [QSA,L]

Another change was the Root directory in httpd.conf:
Original (from package):
<Directory />
AllowOverride none
Require all denied
</Directory>

Suggested by CakePHP: (and the one that is working now)
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>

Well, I got my API working, monitors.json, getVersion.json,events.json, etc,etc


BTW, I also change the Bundle CakePHP (2.5) with a 2.8.5 from github. I believe that I was getting an error about CakeText name already defined before updating CakePHP and it was fixed after that.


Thank you very much!
Andres

PS: If someone is struggling with their APIs: Please know this: make the page http://server/zoneminder/api to show the 5 green bars of information. That it's a good indicator of progress. Follow the guide for rewrite url on CakePHP website, make sure that your web server has the rewrite module loaded and check the permission of the files under api to be owned by whoever is running the webserver. I think that is in a nutshell where the problems where found in my case, and I hope it can save some ones time in troubleshooting their case.
Locked