I am using the snapshot version of icinga2 for the api feature . I was able to successfully add hostgroups and hosts dynamically through the api and query them .
However , i am not able to see the hostgroup added through the api in icingaweb2 .
Here is what i am doing :
To add hostgroup : curl -k -s -u icingaadmin:icinga 'https://localhost:5665/v1/objects/hostgroups/testgrp' -X PUT -d '{ "attrs": { "name" : "testgrp" ,"display_name" : "testgrp" , "state_loaded" :true }}'
To add host :
curl -k -s -u icingaadmin:icinga 'https://localhost:5665/v1/objects/hosts/8.8.8.8' -X PUT -d '{ "templates": [ "generic-host" ], "attrs": { "address": "8.8.8.8" , "groups" : [ "testgrp" ]} }'
In the UI , i am not able to see the hostgroup created through the API ,however the host is visible in UI .