Page 1 of 1

API config host - how to configure hostgroup inheritance

Posted: Fri Mar 21, 2025 8:55 am
by hostgroupguy
I'm using Nagios XI API to configure my hosts. I'm able to do it successfully except for hostgroup inheritance.

The options for choosing hostgroup inheritance for host in the GUI are standard, null or +.
In my code I'm posting hostgroups like this:

Code: Select all

$hostgroup="+hostgroup1,hostgroup2"
curl -X POST "$ENDPOINT" -d "hostgroups=$hostgroups"
It seems that nagios deletes the + all together cause in the GUI option standard is selected?

Thanks for your help.

Re: API config host - how to configure hostgroup inheritance

Posted: Fri Mar 21, 2025 2:20 pm
by DoubleDoubleA
It might be that the + is being interpreted as a space due to url encoding.

try:

Code: Select all

$hostgroup="%2Bhostgroup1,hostgroup2"

Re: API config host - how to configure hostgroup inheritance

Posted: Mon Mar 24, 2025 2:26 am
by hostgroupguy
That was the case indeed.

Thank you!