Page 1 of 1

May I get an example of using configs API

Posted: Sun Jul 17, 2016 3:53 am
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?

Re: May I get an example of using configs API

Posted: Sat Jul 23, 2016 11:48 am
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

Re: May I get an example of using configs API

Posted: Sat Jul 23, 2016 6:05 pm
by freff
That is exactly the information that I needed and my automation script is now working. Thank you!

Re: May I get an example of using configs API

Posted: Tue Jul 26, 2016 12:47 am
by gert
These examples should *really* be in the docs. Thanks asker!

Re: May I get an example of using configs API

Posted: Tue Jul 26, 2016 12:48 am
by gert
(Really, i should update the API docs myself, since I've been doing a bunch of stuff using them)

Re: May I get an example of using configs API

Posted: Wed Jul 27, 2016 4:14 pm
by asker