API question

Forum for questions and support relating to the 1.34.x releases only.
Post Reply
alabamatoy
Posts: 349
Joined: Sun Jun 05, 2016 2:53 pm

API question

Post by alabamatoy »

I have a script which worked well with 1.30 but wont work with 1.34, so I am trying to rewrite it to make it work with the new version. Very simple, log in, set alarm, sleep, unset alarm, logout. So here's the script (minus some of the surrounding code that's not relevant):

Code: Select all

curl -d "username=[username]&password=[password]&stateful=1" -c /tmp/zmcookies.txt  https://serverdomain.com/zm/api/host/login.json
curl -b /tmp/zmcookies.txt https://serverdomain.com/zm/api/monitors/alarm/id:20/command:on.json
curl -b /tmp/zmcookies.txt https://serverdomain.com/zm/api/monitors/alarm/id:20/command:off.json
curl -b /tmp/zmcookies.txt https://serverdomain.com/zm/api/host/logout.json
The script >> the output from these to a textfile, and here's what I get

Code: Select all

{"access_token":"[long string of text]","access_token_expires":7200,"refresh_token":"[long string of text]","refresh_token_expires":86400,"credentials":"auth="[string of text]","append_password":0,"version":"1.34.22","apiversion":"2.0"}
{"status":""}
{"status":""}
{"result":"ok"}
No alarms get created on monitor 20 :roll: What am I doing wrong?
User avatar
iconnor
Posts: 2900
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: API question

Post by iconnor »

The empty status is no bueno. I'll have to do some testing
User avatar
iconnor
Posts: 2900
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: API question

Post by iconnor »

Works perfectly for me. Those empty status's are bad.

This all works by calling zmu in the backend so zmu logs may have more info.

Might have to do with auth settings, especially AUTH_RELAY. What is yours set to ? If plain, then you may have to put stateful=1 in subsequent commands as well. Which is a bit weird
alabamatoy
Posts: 349
Joined: Sun Jun 05, 2016 2:53 pm

Re: API question

Post by alabamatoy »

iconnor wrote: Tue Dec 22, 2020 2:25 pmThis all works by calling zmu in the backend so zmu logs may have more info.
ZMU logs show "unable to authenticate user"
iconnor wrote: Tue Dec 22, 2020 2:25 pm Might have to do with auth settings, especially AUTH_RELAY. What is yours set to ? If plain, then you may have to put stateful=1 in subsequent commands as well. Which is a bit weird
Currently set to "hashed"
Post Reply