API configuration issues

Forum for questions and support relating to the 1.29.x releases only.
Locked
bforcier
Posts: 4
Joined: Tue Aug 30, 2016 1:31 am

API configuration issues

Post by bforcier »

Hello,
I recently upgraded to 1.29 and am trying to setup the API for use with zmnija. I followed the guide posted on the wiki for apache and zm configuration but I can't get the app to talk to the API. When I do http://serverip/zm/api: I get "The requested URL /zm/api was not found on this server."

http://serverip/zm/api/host/getVersion.json I don't see anything. I actually don't even have a host folder in my api directory.

Everything in /usr/share has the same user/owner (www-data). My apache2.conf has entries described on the wiki. Not sure what else I could be missing.

Thanks
Last edited by bforcier on Tue Aug 30, 2016 11:57 pm, edited 2 times in total.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API configuration issues

Post by asker »

How exactly did you upgrade? Which guide did you follow?
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
bforcier
Posts: 4
Joined: Tue Aug 30, 2016 1:31 am

Re: API configuration issues

Post by bforcier »

I removed with purge, autoremove, and cleared the zm database then followed this:

https://wiki.zoneminder.com/Ubuntu_Serv ... e_easy_way
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API configuration issues

Post by asker »

If you followed that guide verbatim and are sure you did not miss steps, then the Api parh should be server/zm/api not server/api as you wrote below?
bforcier wrote:I removed with purge, autoremove, and cleared the zm database then followed this:

https://wiki.zoneminder.com/Ubuntu_Serv ... e_easy_way
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
bforcier
Posts: 4
Joined: Tue Aug 30, 2016 1:31 am

Re: API configuration issues

Post by bforcier »

Yes. Sorry about that http://serverip/zm/api is what was configured (edited in original) this returns 404.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API configuration issues

Post by asker »

Try these, and please post the exact output from all of these. Thanks.

Code: Select all

sudo a2enmod rewrite

Code: Select all

cat /usr/share/zoneminder/www/api/.htaccess

Code: Select all

cat /usr/share/zoneminder/www/api/app/.htaccess

Code: Select all

cat /usr/share/zoneminder/www/api/app/webroot/.htaccess

Code: Select all

cat /etc/apache2/conf-enabled/zoneminder.conf #replace zoneminder.conf with any other config you may  be using
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Zenw1e
Posts: 10
Joined: Mon Sep 12, 2016 11:04 am

Re: API configuration issues

Post by Zenw1e »

hi, asker!
We have same problem weet API. ZM works good, but our chief wants to explore cameras from he's smartphone (iPhone 6). We have bought zmninja from AppMarket, then install it, But ZMNinja request an API.
My API doesn't work, i' got error (see attachment)
What would i do?
Linux Debian 8.0
ZM 1.29.0

I'm trying by your steps:

Code: Select all

root@stk-video-01:/etc/apache2# a2enmod rewrite
Module rewrite already enabled

root@stk-video-01:/etc/apache2# cat /usr/share/zoneminder/www/api/.htaccess
cat: /usr/share/zoneminder/www/api/.htaccess: No file or directory is found

root@stk-video-01:/etc/apache2# cat /usr/share/zoneminder/www/api/app/.htaccess
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
    RewriteBase /zm/api
</IfModule>

root@stk-video-01:/etc/apache2# cat /usr/share/zoneminder/www/api/app/webroot/.htaccess
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    RewriteBase /zm/api
</IfModule>


root@stk-video-01:/etc/apache2# cat /etc/apache2/conf-enabled/zoneminder.conf
# Remember to enable cgi mod (i.e. "a2enmod cgi").
ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin"
<Directory "/usr/lib/zoneminder/cgi-bin">
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    AllowOverride All
    Require all granted
</Directory>

Alias /zm /usr/share/zoneminder/www
<Directory /usr/share/zoneminder/www>
  php_flag register_globals off
  Options Indexes FollowSymLinks
  <IfModule mod_dir.c>
    DirectoryIndex index.php
  </IfModule>
</Directory>

<Directory /usr/share/zoneminder/www/api>
    AllowOverride All
</Directory>
root@stk-video-01:/etc/apache2#
Attachments
cakephp error.jpg
cakephp error.jpg (205.75 KiB) Viewed 6252 times
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API configuration issues

Post by asker »

Are you sure you did

sudo a2enmod rewrite
edit: looks like you already did it

How exactly did you upgrade?
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API configuration issues

Post by asker »

Hmm, looks like your .htaccess file is missing in api/ - not sure how you upgraded

Try this:

Code: Select all

cp /usr/share/zoneminder/www/api/app/.htaccess /usr/share/zoneminder/www/api/.htaccess
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Zenw1e
Posts: 10
Joined: Mon Sep 12, 2016 11:04 am

Re: API configuration issues

Post by Zenw1e »

Thanx, i tried to

Code: Select all

root@stk-video-01:/etc/apache2# cp /usr/share/zoneminder/www/api/app/.htaccess /usr/share/zoneminder/www/api/.htaccess
then try to open.
I have no upgrade to 1.29.0
Clear install was be with 1.29.0 version.
Attachments
internal error.jpg
internal error.jpg (68.25 KiB) Viewed 6211 times
Zenw1e
Posts: 10
Joined: Mon Sep 12, 2016 11:04 am

Re: API configuration issues

Post by Zenw1e »

Thanx a lot, asker!
I have solved my problem.
Problem was in file:

Code: Select all

root@stk-video-01:/usr/share/zoneminder/www/api# cat /usr/share/zoneminder/www/api/.htaccess
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$   /webroot/    [L]
    RewriteRule    (.*) /webroot/$1    [L]
    RewriteBase /zm/api
</IfModule>
In this case API doesn't work. But i turn on my other ZM server and make:

Code: Select all

root@stk-video-01:/usr/share/zoneminder/www/api# cat /usr/share/zoneminder/www/api/.htaccess
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$   app/webroot/    [L]
    RewriteRule    (.*) app/webroot/$1    [L]
    RewriteBase /zm/api
</IfModule>
Then, i corrected my /usr/share/zoneminder/www/api/.htaccess file and paste "app", reload apache2 and GOOD!
THANX!
Attachments
api_work.jpg
api_work.jpg (331.79 KiB) Viewed 6208 times
Locked