Director Rest API post for modify object is wrong working

Hi all,

When I try to modify the host object with the director API, all the vars properties are crushed. I want just add new vars property to existing host object. Is this a or bug?

curl -k -s -S -i -u ‘user:pass’ -H ‘Accept: application/json’ -X POST ‘https://icinga-host/icingaweb2/director/host?name=hostname1’ -d ‘{“vars”: { “event”: [ “Icinga”, “Camp” ] }}’


I think it’s expected as your API call sets the variable vars to value { “event”: [ “Icinga”, “Camp” ] } and this overwrites the old content of vars.
Maybe you could try to address vars.event directly with -d '{"vars.event": [ "Icinga", "Camp" ] }'?

this format was not accepted by the director api

It should work this way according to the documentation.

The response always returns the full object on modification. This way you can immediately investigate the merged result. As you can see, POST requests only touch the parameters you passed - the rest remains untouched.

One more example to prove this:

{"address": "", "vars.event": "Icinga CAMP" }

If I understand the problem correctly, it could be that the Array [ “list element 1”, “element2” ] is not allowed but “string” is.

I am sorry ‘{“vars.event”: [ “Icinga”, “Camp” ] }’ and ‘{“vars.event”: “Icinga CAMP” }’ both work.

I got error because " ‘ " I tried with this character instead of " ’ " in bash command line :slight_smile:

1 Like