API not working after upgrade

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
Mozart
Posts: 17
Joined: Fri Aug 26, 2016 8:41 am

API not working after upgrade

Post by Mozart »

This morning I upgraded my 1.34.26 zoneminder to 1.36.0. Upgrade seems to went well. Everything is working, I can use all items/options through the website but when I use zmninja, things do not work anymore. I created a issue on the zmninja github and from that it appears that the api is not working. The issue on the zmninja github is here: https://github.com/pliablepixels/zmNinja/issues/1066

They asked me to test the api from the browser and then I get this error:

Code: Select all

 {"success":false,"data":{"name":"An Internal Error Has Occurred.","message":"An Internal Error Has Occurred.","url":"\/zm\/api\/monitors\/index\/Type%20!=:WebSite.json","exception":{"class":"PDOException","code":"42S22","message":"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Monitor.HourEvents' in 'field list'"}}}
Any ideas what to do to fix this?
User avatar
swolsen
Posts: 31
Joined: Sat Mar 20, 2021 9:39 pm
Location: Schenectady, NY, USA

Re: API not working after upgrade

Post by swolsen »

I do like the new design and it seems to be working very well. Especially the low dev/shm.

Re: API - I too seem to be getting the same error on my script.

{"success":false,"data":{"name":"An Internal Error Has Occurred.","message":"An Internal Error Has Occurred.","url":"\/zm\/api\/monitors\/3.json?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjIxMTE2Nzk3LCJleHAiOjE2MjExMjM5OTcsInVzZXIiOiJzY290dCIsInR5cGUiOiJhY2Nlc3MifQ.Vi-kwA0cdTR6HrivRMHVJUO5w1jBQ40Epj29NDXp4rA","exception":{"class":"PDOException","code":"42S22","message":"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Monitor.HourEvents' in 'field list'"}}}PHP Notice: Undefined property: stdClass::$monitor in /home/scott/Scripts/zm-setMonitorFunction on line 58
Mozart
Posts: 17
Joined: Fri Aug 26, 2016 8:41 am

Re: API not working after upgrade

Post by Mozart »

Without changing anything it started to work. Maybe the database upgrade was still busy? Is that a background process?
User avatar
swolsen
Posts: 31
Joined: Sat Mar 20, 2021 9:39 pm
Location: Schenectady, NY, USA

Re: API not working after upgrade

Post by swolsen »

Yes, same here.
fran.roo
Posts: 5
Joined: Mon May 17, 2021 1:30 am

Re: API not working after upgrade

Post by fran.roo »

I had my machine running Ubuntu server 18.04, adding a second hard drive for another project, I managed to mess it up.
Anyhow started over installing Ubuntu server 20.04, installed Open SSH, installed LAMP, installed ZM 1.34, which the zm url did not work, upgraded to 1.36 in an attempt to fix it.
Also updated timezone in the php.ini file and fixed the hour value in the computers BIOS (Date was okay, just the hour was off)

Anyhow when I navigate to the url on my computer ( http://192.168.1.253/zm/ ), the page just displays the text shown in the attached text file.
Looking for some pointers on what I can try to fix my issue, thanks!



Yes, Apache is running when I go here: http://192.168.1.253/
I am not behind a proxy server
I can ping the server from Windows
Running the command: dpkg -s zoneminder | grep Version
Give me this: Version: 1.36.0-focal1
Attachments
ZM_MainPageResults.txt
(7.11 KiB) Downloaded 124 times
fran.roo
Posts: 5
Joined: Mon May 17, 2021 1:30 am

Re: API not working after upgrade

Post by fran.roo »

Fixed! had to run the post install items:
Configure MySQL, ZM, restart ZM and Apache...

It had a few years since my first install!

Now back to wrangling with zones for sun / shadows balance
vorgon
Posts: 1
Joined: Mon Jun 14, 2021 6:13 pm

Re: API not working after upgrade

Post by vorgon »

I had the same issue and finally tracked it down to a caching issue. If you upgrade from 1.34 to 1.36, the cached API models (from 1.34) need to be updated. It took me too long to work this out!

The easiest way that I found to do this was to set the API into debug mode (once) and then back into production mode. Simple 3 steps:

1. Enable debug mode
2. Retrieve an API URL
3. Disable debug mode

Note: My installation is running on Centos 8 - your files may be in a different place - but, in principle, this should work regardless of distribution.

1. Enable debug mode

Edit /usr/share/zoneminder/www/api/app/Config/core.php

Change line 34 from:

Code: Select all

Configure::write('debug', 0);
to:

Code: Select all

Configure::write('debug', 1);
Retrieve an API URL

In a browser, go here: https://<your_zm_instance_url>/zm/api/monitors/index/Type%20!=:WebSite.json

You should see a load of JSON starting with "monitors".

3. Disable debug mode

Edit /usr/share/zoneminder/www/api/app/Config/core.php

Change line 34 from:

Code: Select all

Configure::write('debug', 1);
to:

Code: Select all

Configure::write('debug', 0);

And you're done.
RusFM
Posts: 7
Joined: Thu Oct 18, 2018 2:49 pm

Re: API not working after upgrade

Post by RusFM »

Vorgon,

Thanks, that worked for me!

Rus
thefuzz4
Posts: 28
Joined: Sat Mar 01, 2014 5:43 am

Re: API not working after upgrade

Post by thefuzz4 »

Thank you for that tip that did the trick for me with the debug. Finally did my upgrade to 1.36 today.
Mozart
Posts: 17
Joined: Fri Aug 26, 2016 8:41 am

Re: API not working after upgrade

Post by Mozart »

Thanks, this helped me too in migrating to 1.36 :)
Post Reply