Can view, but can't edit via API

Forum for questions and support relating to the 1.29.x releases only.
Locked
red-dog
Posts: 5
Joined: Mon Dec 28, 2009 7:32 pm

Can view, but can't edit via API

Post by red-dog »

I previously had ZM 1.29.0 working on a Centos 6 server and I could modify my ZM configuration via the API via the "-d" directive. After a hard drive crash, I upgraded to Centos 7.2 and reinstalled ZM 1.29.0. Everything works fine, including viewing ZM's configs via the API, but any attempt to modify the configuration via "-d" generates a "Missing Method in MonitorsController" error.

/zm/api shows CakePHP 2.5.0-RC1 and everything is green except the last line which notes that DebugKit is not installed.

The following commands return the expected response:
/zm/api/configs.json
/zm/api/events.json
/zm/api/monitors/1.json
/zm/api/events/181.json -d "Event[Name]=Seek and Destroy"

With /zm/api/monitors/1.json -d "Monitor[Brightness]=30000" throwing an error.

CentOS 7.2.1511
ZoneMinder 1.29.0
API Version 1.0
PHP 5.4.16

Any suggestions on where to look would be appreciated.
Missing Method
Missing Method
zm api.jpg (439.19 KiB) Viewed 2271 times
red-dog
Posts: 5
Joined: Mon Dec 28, 2009 7:32 pm

Re: Can view, but can't edit via API

Post by red-dog »

After further investigation, values are being set, but I'm still seeing some strange behavior.

I would have sworn that I was able to change setting from a web browser before with http://zm/api/monitors/1.json -d "Monitor[Brightness]=30000". That's where I was seeing the error that was include in the original post. When I attempted to set values using curl, I was receiving a bunch of HTML and I assumed that it was the same error message. Upon closer inspection, it says that it has saved my values, however it is still giving an error message. Since I've always used a the "-s" curl directive, these errors may have been there all along.

So values are getting changed and they are being stored properly in mySql, however the values that show up in the zm console are different than the configured values. If I set Monitor[Brightness]=30000, zm console shows 29952. If I set it to 20000, zm shows 19968. I just noticed that same thing happens when I try to adjust the brightness in the zm console. If I set the brightness to 30000, as soon as I hit save, it changes to 29952.

Here is the response I get to: curl -XPUT http://192.168.0.7/zm/api/monitors/1.json -d "Monitor[Brightness]=30000"

<pre class="cake-error"><a href="javascript:void(0);" onclick="document.getElementById('cakeErr5750385b863b5-trace').style.display = (document.getElementById('cakeErr5750385b863b5-trace').style.display == 'none' ? '' : 'none');"><b>Notice</b> (8)</a>: Undefined index: Type [<b>APP/Controller/MonitorsController.php</b>, line <b>242</b>]<div id="cakeErr5750385b863b5-trace" class="cake-stack-trace" style="display: none;"><a href="javascript:void(0);" onclick="document.getElementById('cakeErr5750385b863b5-code').style.display = (document.getElementById('cakeErr5750385b863b5-code').style.display == 'none' ? '' : 'none')">Code</a> <a href="javascript:void(0);" onclick="document.getElementById('cakeErr5750385b863b5-context').style.display = (document.getElementById('cakeErr5750385b863b5-context').style.display == 'none' ? '' : 'none')">Context</a><pre id="cakeErr5750385b863b5-code" class="cake-code-dump" style="display: none;"><code><span style="color: #000000"><span style="color: #0000BB">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}</span></span></code>
<code><span style="color: #000000"><span style="color: #0000BB"></span></span></code>
<span class="code-highlight"><code><span style="color: #000000"><span style="color: #0000BB">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$monitor</span><span style="color: #007700">[</span><span style="color: #DD0000">'Type'</span><span style="color: #007700">]&nbsp;==&nbsp;</span><span style="color: #DD0000">'Local'</span><span style="color: #007700">)&nbsp;{</span></span></code></span></pre><pre id="cakeErr5750385b863b5-context" class="cake-context" style="display: none;">$id = '1'
$command = 'restart'
$monitor = array(
'Monitor' => array(
'Brightness' => '30000'
)
)
$daemon = null
$args = ''
$daemons = array()</pre><pre class="stack-trace">MonitorsController::daemonControl() - APP/Controller/MonitorsController.php, line 242
MonitorsController::edit() - APP/Controller/MonitorsController.php, line 141
ReflectionMethod::invokeArgs() - [internal], line ??
Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 490
AppController::invokeAction() - APP/Plugin/Crud/Lib/CrudControllerTrait.php, line 31
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 191
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 165
[main] - APP/webroot/index.php, line 108</pre></div></pre><pre class="cake-error"><a href="javascript:void(0);" onclick="document.getElementById('cakeErr5750385b86b3b-trace').style.display = (document.getElementById('cakeErr5750385b86b3b-trace').style.display == 'none' ? '' : 'none');"><b>Notice</b> (8)</a>: Undefined index: Function [<b>APP/Controller/MonitorsController.php</b>, line <b>248</b>]<div id="cakeErr5750385b86b3b-trace" class="cake-stack-trace" style="display: none;"><a href="javascript:void(0);" onclick="document.getElementById('cakeErr5750385b86b3b-code').style.display = (document.getElementById('cakeErr5750385b86b3b-code').style.display == 'none' ? '' : 'none')">Code</a> <a href="javascript:void(0);" onclick="document.getElementById('cakeErr5750385b86b3b-context').style.display = (document.getElementById('cakeErr5750385b86b3b-context').style.display == 'none' ? '' : 'none')">Context</a><pre id="cakeErr5750385b86b3b-code" class="cake-code-dump" style="display: none;"><code><span style="color: #000000"><span style="color: #0000BB">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}</span></span></code>
<code><span style="color: #000000"><span style="color: #0000BB"></span></span></code>
<span class="code-highlight"><code><span style="color: #000000"><span style="color: #0000BB">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$monitor</span><span style="color: #007700">[</span><span style="color: #DD0000">'Function'</span><span style="color: #007700">]&nbsp;==&nbsp;</span><span style="color: #DD0000">'Monitor'</span><span style="color: #007700">)&nbsp;{</span></span></code></span></pre><pre id="cakeErr5750385b86b3b-context" class="cake-context" style="display: none;">$id = '1'
$command = 'restart'
$monitor = array(
'Monitor' => array(
'Brightness' => '30000'
)
)
$daemon = null
$args = '-m 1'
$daemons = array()</pre><pre class="stack-trace">MonitorsController::daemonControl() - APP/Controller/MonitorsController.php, line 248
MonitorsController::edit() - APP/Controller/MonitorsController.php, line 141
ReflectionMethod::invokeArgs() - [internal], line ??
Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 490
AppController::invokeAction() - APP/Plugin/Crud/Lib/CrudControllerTrait.php, line 31
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 191
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 165
[main] - APP/webroot/index.php, line 108</pre></div></pre>{
"message": "Saved"
}
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Can view, but can't edit via API

Post by asker »

Seems to work well for me. Your error is complaining of some missing index type/functions - the line #s are different from the MonitorsController I have. Try making a backup of MonitorsController.php and replace with https://github.com/ZoneMinder/ZoneMinde ... roller.php -- see if you get past that error
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
red-dog
Posts: 5
Joined: Mon Dec 28, 2009 7:32 pm

Re: Can view, but can't edit via API

Post by red-dog »

Getting error, but it is slightly different now. It's not a big deal, since it's sort of working now. By the way, if you set Brightness to 30000 does it show as 30000 within zm?

<pre class="cake-error"><a href="javascript:void(0);" onclick="document.getElementById('cakeErr5750de8cc4521-trace').style.display = (document.getElementById('cakeErr5750de8cc4521-trace').style.display == 'none' ? '' : 'none');"><b>Notice</b> (8)</a>: Undefined index: Device [<b>APP/Controller/MonitorsController.php</b>, line <b>324</b>]<div id="cakeErr5750de8cc4521-trace" class="cake-stack-trace" style="display: none;"><a href="javascript:void(0);" onclick="document.getElementById('cakeErr5750de8cc4521-code').style.display = (document.getElementById('cakeErr5750de8cc4521-code').style.display == 'none' ? '' : 'none')">Code</a> <a href="javascript:void(0);" onclick="document.getElementById('cakeErr5750de8cc4521-context').style.display = (document.getElementById('cakeErr5750de8cc4521-context').style.display == 'none' ? '' : 'none')">Context</a><pre id="cakeErr5750de8cc4521-code" class="cake-code-dump" style="display: none;"><code><span style="color: #000000"><span style="color: #0000BB"></span></span></code>
<code><span style="color: #000000"><span style="color: #0000BB">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$monitor</span><span style="color: #007700">[</span><span style="color: #DD0000">'Type'</span><span style="color: #007700">]&nbsp;==&nbsp;</span><span style="color: #DD0000">'Local'</span><span style="color: #007700">)&nbsp;{</span></span></code>
<span class="code-highlight"><code><span style="color: #000000"><span style="color: #0000BB">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$args&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"-d&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$monitor</span><span style="color: #007700">[</span><span style="color: #DD0000">'Device'</span><span style="color: #007700">];</span></span></code></span></pre><pre id="cakeErr5750de8cc4521-context" class="cake-context" style="display: none;">$id = '1'
$command = 'restart'
$monitor = array(
'Type' => 'Local',
'Function' => 'Modect'
)
$daemon = null
$args = ''
$daemons = array()</pre><pre class="stack-trace">MonitorsController::daemonControl() - APP/Controller/MonitorsController.php, line 324
MonitorsController::edit() - APP/Controller/MonitorsController.php, line 142
ReflectionMethod::invokeArgs() - [internal], line ??
Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 490
AppController::invokeAction() - APP/Plugin/Crud/Lib/CrudControllerTrait.php, line 31
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 191
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 165
[main] - APP/webroot/index.php, line 108</pre></div></pre>{
"message": "Saved"
fireport
Posts: 1
Joined: Thu Jul 07, 2016 7:42 pm

Re: Can view, but can't edit via API

Post by fireport »

I have the same kind of problem, with fedora 24 and zoneminder 1.29.0, when i try di enable/disable monitors
Cattura.PNG
Cattura.PNG (119.69 KiB) Viewed 2166 times
Locked