REST API - POST - Make use of templates

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
brdr
Posts: 312
Joined: Mon Jun 02, 2014 12:49 pm

REST API - POST - Make use of templates

Post by brdr »

Hi,

We use XI 5.2.2

My question relates to this post. Using REST API to update host's description....

https://support.nagios.com/forum/viewto ... 16&t=38469

Question: When I use the REST API POST... this call requires check/alert settings and values in the call. When the call completes it inserts these check and alert settings into the updated host. The issue for us is that we use templates exclusively to set each host's check/alert settings. Is there a way to use the POST call without having to pass in these settings?

As always thank you.
brdr
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: REST API - POST - Make use of templates

Post by rkennedy »

You should be able to do so by appending &force=1 (which will skip validation checks). See the example below as an example -

Code: Select all

[root@localhost libexec]# curl -XPOST "http://192.168.4.179/nagiosxi/api/v1/config/host?apikey=uui5lt5s&pretty=1" -d "host_name=testtemplate&address=128.0.0.1&use=linux-server"        {
    "error": "Missing required variables",
    "missing": [
        "max_check_attempts",
        "check_period",
        "notification_interval",
        "notification_period",
        "contacts OR contact_groups"
    ]
}

[root@localhost libexec]# curl -XPOST "http://192.168.4.179/nagiosxi/api/v1/config/host?apikey=uui5lt5s&pretty=1" -d "host_name=testtemplate&address=128.0.0.1&use=linux-server&force=1"
{
    "success": "Successfully added testtemplate to the system. Config imported but not yet applied."
}
Keep in mind if you do not inherit everything, there isn't any validation check running to make sure your template is proper so you could encounter more errors if it isn't setup properly.
Former Nagios Employee
Locked