May I get an example of using configs API

Forum for questions and support relating to the 1.29.x releases only.
Locked
freff
Posts: 6
Joined: Sun Jul 17, 2016 3:41 am

May I get an example of using configs API

Post by freff »

Hello,

I am running zoneminder 1.29.0 and am successfully using the API via shell and python scripts to manipulate some monitor settings. However, I am attempting to edit the ZM_MESSAGE_ADDRESS using the config API. I can't figure out the proper syntax. The API documentation does not provide examples of configuration changes via API and simply says that "(Example of changing config TBD)"

I am able to dump the list of config API's using curl -b cookies.txt -XGET http://server/zm/api/configs.json

I have tried to edit ZM_MESSAGE_ADDRESS using all sorts of XPUT such as
curl -b cookies.txt -XPUT http://server/zm/api/configs/117.json -d "Config[Value]=test@test.com"

But I can not seem to find the proper syntax. Would anyone please be able to help me with the config api syntax for changing non read-only settings?
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: May I get an example of using configs API

Post by asker »

The configs API is a bit quirky. I think the issue lies in the primary key being defined as the name of the Config instead of the integer ID like others. I need to do some experimenting to see why this breaks the normal flow.

Anyhow, to get it working, here is what you need to to


To change the "Value" of ZM_X10_HOUSE_CODE from A to B:

Code: Select all

curl -XPUT http://server/zm/api/configs/edit/ZM_X10_HOUSE_CODE.json -b cookies.txt -d "Config[Value]=B"
curl -XGET http://server/zm/api/configs/view/ZM_X10_HOUSE_CODE.json -b cookies.txt
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
freff
Posts: 6
Joined: Sun Jul 17, 2016 3:41 am

Re: May I get an example of using configs API

Post by freff »

That is exactly the information that I needed and my automation script is now working. Thank you!
gert
Posts: 14
Joined: Fri Jul 01, 2016 12:43 am

Re: May I get an example of using configs API

Post by gert »

These examples should *really* be in the docs. Thanks asker!
gert
Posts: 14
Joined: Fri Jul 01, 2016 12:43 am

Re: May I get an example of using configs API

Post by gert »

(Really, i should update the API docs myself, since I've been doing a bunch of stuff using them)
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: May I get an example of using configs API

Post by asker »

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
Locked