Hi Everyone,
I’m new to the forum and it’s my first post.
I’m trying to automate stuff for our checkmk apps and its a good thing with v2 rest api is introduced. But, I find it quite troublesome and quite hard to follow. If there could be more example that checkmk team can provide to run these actions. Hehe.
Anyway, hope anyone could help me with my issue. I’m trying out the rest api for checkmk v2 and I got stuck when I tried to add a contactgroup in the mix. It tells me that my entry is not a valid string. Anyone encounter the same issue when creating their hosts? See the code below.
out=$(
curl
–request POST
–write-out “\nxxx-status_code=%{http_code}\n”
–header “Authorization: Bearer autouser $automation_secret”
–header “Accept: application/json”
–header “Content-Type: application/json”
–data ‘{ “attributes”: { “site”: “mastertest”, “contactgroups”: { “groups”: [ “contactgroup1”, “contactgroup2”, “server1-cg” ] }, “tag_os”: “lin” }, “folder”: “/servers/site1”, “host_name”: “server1.example.com” }’
“$uri/domain-types/host_config/collections/all”)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 387 100 161 100 226 1226 1721 --:–:-- --:–:-- --:–:-- 1725
echo $out
{“title”: “Bad Request”, “status”: 400, “detail”: “These fields have problems: attributes”, “fields”: {“attributes”: {“contactgroups”: [“Not a valid string.”]}}} xxx-status_code=400
echo $uri
https://test-monitoring.example.com/mastertest/check_mk/api/1.0
Thanks!

