Just thought I'd share a tip, I ran across a need to remove a free variable from a host via the API. I wasn't able to find a good way to do so directly using commands in the API without simply replacing the host. So that's what I did.
In the scripting that we use for interfacing our ChatOps environment with Nagios XI, I already had code to allow for collecting the existing free variables so that it was additive instead when we would run that specific command. To that, I added code to detect when the value of a free variable is set to "-", and if so, eliminate it from the list of free variables. Then I simply add the host again with the list of free variables, hostgroups, etc. and voila. Free variable gone via the API.
Removing a host free variable via the API
Re: Removing a host free variable via the API
Thanks for the tip @krutaw.
Be sure to check out our Knowledgebase for helpful articles and solutions!