unable to connect to API V1.34.22

Forum for questions and support relating to the 1.34.x releases only.
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: unable to connect to API V1.34.22

Post by david1234 »

I have set the authentication off , abd try this:

Code: Select all

 curl -X POST http://10.0.0.105/zm/api/host/getVersion.json
got the same resualt

Code: Select all

{"name":"Not Found","message":"Not Found","url":"\/api\/zm\/api\/host\/getVersion.json"}
and in the access file

Code: Select all

zm:80 10.0.0.105 - - [29/Nov/2020:15:10:30 +0200] "POST /zm/api/host/getVersion.json HTTP/1.1" 404 252 "-" "curl/7.64.0"
what do you mean by
free of .htaccess files
to search this files in all he PI?
how do I do this ? do you know the linux command for this ?

I have look at all the folders you told me

from
/usr/share/zoneminder/www/
to
/usr/share/zoneminder/www/api/app/webroot/

none of them have fileswith .htaccess ending (if I understand you correct)

when I enter http://10.0.0.105/zm/api

I get

Code: Select all

"Not Found"

Error: The requested address '/api/zm/api/' was not found on this server.
what else can I check ?
Thank you
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: unable to connect to API V1.34.22

Post by Magic919 »

This highlights a problem - /api/zm/api/

That suggests a rewrite error to me.

Run

Code: Select all

find /usr/share/zoneminder/ -name .htaccess 
-
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: unable to connect to API V1.34.22

Post by david1234 »

return empty

Code: Select all

find /usr/share/zoneminder/ -name .htaccess
pi@raspberrypi:~$ 

Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: unable to connect to API V1.34.22

Post by Magic919 »

Can you confirm you switched to the Apache config suggested on the previous page. I’m out of suggestions otherwise.
-
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: unable to connect to API V1.34.22

Post by david1234 »

first of all thank you for your help and time !
I think so , but how can I be 100% sure
what do you wnat to me to run \ which command so we all be sure of that ?

Thanks ,
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: unable to connect to API V1.34.22

Post by Magic919 »

There is no simple way to check the running config for Apache, which is a shame.

You mentioned two config files (which should be one file and a symlink).

Code: Select all

/etc/apache2/sites-enabled/zoneminder.conf
 /etc/apache2/sites-available/zoneminder.conf
 
Run these

Code: Select all

sudo apache2ctl -S
sudo diff /etc/apache2/sites-available/zoneminder.conf /etc/apache2/sites-enabled/zoneminder.conf
sudo grep api /etc/apache2/sites-available/zoneminder.conf
sudo grep api /etc/apache2/sites-enabled/zoneminder.conf
Re-run your checks for the .htaccess files (this is the whole filename, not an extension). Use 'sudo ls -la' to show hidden files.
-
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: unable to connect to API V1.34.22

Post by david1234 »

1.both files are the same as I was told to put

2.

Code: Select all

 sudo apache2ctl -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, 
using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80                   zm (/etc/apache2/sites-enabled/zoneminder_backup.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default 
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: ENABLE_USR_LIB_CGI_BIN
User: name="www-data" id=33
Group: name="www-data" id=33

sudo diff /etc/apache2/sites-available/zoneminder.conf /etc/apache2/sites-enabled/zoneminder.conf

pi@raspberrypi:~$ sudo grep api /etc/apache2/sites-available/zoneminder.conf
<Directory "/usr/share/zoneminder/www/api">
   RewriteBase /zm/api
<Directory "/usr/share/zoneminder/www/api/app">
   RewriteBase /zm/api
<Directory "/usr/share/zoneminder/www/api/app/webroot">
    RewriteBase /zm/api

pi@raspberrypi:~$ sudo grep api /etc/apache2/sites-enabled/zoneminder.conf
<Directory "/usr/share/zoneminder/www/api">
   RewriteBase /zm/api
<Directory "/usr/share/zoneminder/www/api/app">
   RewriteBase /zm/api
<Directory "/usr/share/zoneminder/www/api/app/webroot">
    RewriteBase /zm/api
still get empty resualt

Code: Select all

pi@raspberrypi:~$ sudo find /usr/share/zoneminder/ -name .htaccess 
pi@raspberrypi:~$ 

Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: unable to connect to API V1.34.22

Post by Magic919 »

Ok. You are not using the Apache config file you think.

This bit - *:80 zm (/etc/apache2/sites-enabled/zoneminder_backup.conf:1

Apache is expecting to use any file ending .conf. Either (re)move it or name it zoneminder.conf.backup. Restart Apache, check again.

Looks ok otherwise.
-
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: unable to connect to API V1.34.22

Post by david1234 »

I remove the file
now this is all I have in the site-enabled:

Code: Select all

 ls -lsta /etc/apache2/sites-enabled/
total 12
4 drwxr-xr-x 2 root root 4096 Nov 30 11:35 .
4 drwxr-xr-x 8 root root 4096 Nov 25 10:26 ..
0 lrwxrwxrwx 1 root root   34 Apr 29  2020 zoneminder.conf -> ../sites-available/zoneminder.conf
I have restart the appache
pi@raspberrypi:~$ sudo systemctl stop apache2.service
pi@raspberrypi:~$
pi@raspberrypi:~$ sudo systemctl start apache2.service
pi@raspberrypi:~$ sudo systemctl status apache2.service
apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-11-30 11:38:15 IST; 5s ago
stil get the same resualt

Code: Select all

 curl -X POST http://10.0.0.105/zm/api/getVersion.json
{"name":"Not Found","message":"Not Found","url":"\/zm\/api\/getVersion.json"}
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: unable to connect to API V1.34.22

Post by Magic919 »

This bit is perhaps a typo

curl -X POST http://10.0.0.105/zm/api/getVersion.json

Should be
curl -X POST http://10.0.0.105/zm/api/host/getVersion.json

I'm out of ideas, sorry.
-
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: unable to connect to API V1.34.22

Post by david1234 »

:shock: :shock: :shock:

now it's working

Thank you so much!!!!!

I have enable the password on the gui
and I get this replay

Code: Select all

pi@raspberrypi:~$ curl -XPOST -d "user=David&pass=Davidpass" http://10.0.0.105/zm/api/host/login.json
{"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjA2NzM2NTgzLCJleHAiOjE2MDY3NDM3GF11InVzZXIiOiJEYXZpZCI
sInR5cGUiOiJhY2Nlc3MifQ.cwI4AgkDmtvMHaZwTcUns443ZlffuCyTyz_DhhhF860","access_token_expires":7200,"refresh_token":"eyJ0eXAiOiJKVAEbGciOiJIUzI
1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjA2NzM2NTgzLCJleHAiOjE2MDY4MjI5ODMsInVzZXIiOiJEYXZpZCIsInR5cGUiOiJyZWZyZXNoIn0.bSTj7AogaSJtk0mBZ5gUZrV
s5XygYLB00CT5VxuMDVA","refresh_token_expires":86400,"version":"1.34.22","apiversion":"2.0"}
I guess this in fine now

so now I can connect using Ninja and\or create my own small code to enable\disable camera recording?
Thank you so much !!!!!

can you say what was the problem ?
the config file ?


maybe this post need to be mark for rapsberry pi users ??

Thanks !
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: unable to connect to API V1.34.22

Post by Magic919 »

In general, Pi users should follow the approved guides as it's quite hard to work out how to help once they reach here.

As I mentioned, this looked like a rewrite problem. The original Apache config you posted said -

Code: Select all

RewriteBase /api
The one you were directed to has

Code: Select all

RewriteBase /zm/api
This can be defined in the Apache config (as here) or put in an .htaccess file. Your own progress with the fix was slowed due to the 'backed up' Apache config still being live.

Hopefully you can get on and enjoy ZMNinja and ZM.
-
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: unable to connect to API V1.34.22

Post by david1234 »

as I post at the beggining
I use a well known image to install it - didn't change anything .

but never mind - I thought maybe this is a "well- knonwn" problem that mught help otehr PI users .

I was 99% happy with zoneminder (for what I need , all the time record ) , just wanted to add remote control to stop\start recording

I will start wroking on it now using python

Thank you so much again !
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: unable to connect to API V1.34.22

Post by Magic919 »

I'm glad we got there in the end.

I'm a user of the API and also zmeventnoticationserver (ZMES). I'd guess that Pi users following that install path don't often use the API. I don't know.

Hope your next bit goes well.
-
Post Reply