Page 1 of 1

REST api required variables

Posted: Thu Jan 17, 2019 10:04 am
by WillemDH
Hello,

I'm wondering why the nagiosxi/api/v1/config/service config rest api requires certain variables to be set. More specific I'm speaking about:

Code: Select all

"json": {
        "error": "Missing required variables",
        "missing": [
            "max_check_attempts",
            "check_interval",
            "retry_interval",
            "notification_interval"
        ]
    },
As we use service templates which hold these values, forcing us to set these variables with the rest api kind of obsoletes the service template?

Grtz

Willem

Re: REST api required variables

Posted: Thu Jan 17, 2019 3:22 pm
by lmiltchev
Without these variables, configuration would fail. The REST API wouldn't know if all of these are inherited from a template... Having said that, if you are sure your configuration is OK, you could force the command, and still use templates.

Example:

Code: Select all

# curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/config/service?apikey=xxx&pretty=1" -d "host_name=testapihost&service_description=PING&use=xiwizard_linuxserver_ping_service&force=1&applyconfig=1"
{
    "success": "Successfully added testapihost :: PING to the system. Config applied, Nagios Core was restarted."
}
Here's the config of the new PING service that was added:

Code: Select all

define service {
    host_name              testapihost
    service_description    PING
    use                    xiwizard_linuxserver_ping_service
    register               1
}