Page 1 of 1

Nagios API Put Contact

Posted: Wed Jun 19, 2019 4:20 am
by infofedsec
I've been looking at utilising the API to help with our oncall implementation. I was attempting to use the put contact to update the email address for a contact however when i try i get the following

curl -XPUT "http://[nagios address]/api/v1/config/contact/testcontact?apikey=[secret api key]&pretty=1&email=jsmith"
{
"success": "Updated testcontact in the system. Config imported but not yet applied."
}

When i check why its not restarted it's because it's created a blank command as testcontact instead of updating the already created contact testcontact. When using post or delete it works correctly but put contact doesn't seem to work.

I'm using 5.6.3

Re: Nagios API Put Contact

Posted: Wed Jun 19, 2019 10:05 am
by lmiltchev
I was able to recreate the issue - there is a typo in one of the files. :(

Open /usr/local/nagiosxi/html/api/includes/utils-api.inc.php in a text editor, and go to line 387. Replace this:

Code: Select all

api_config_edit_cfg_command
with this:

Code: Select all

api_config_edit_cfg_contact
Let us know if this helped.

Re: Nagios API Put Contact

Posted: Thu Jun 20, 2019 3:14 am
by infofedsec
This solved the problem, it updates the contact, I still get "config imported but not applied" when i run the command though

Re: Nagios API Put Contact

Posted: Thu Jun 20, 2019 6:46 am
by scottwilkerson
This part is normal, if you want to apply configuration immediately, you would want to add the following to the URL in the curl command

Code: Select all

&applyconfig=1

Re: Nagios API Put Contact

Posted: Fri Jun 21, 2019 9:25 am
by infofedsec
Thank you for your help. You can lock this if you like

Re: Nagios API Put Contact

Posted: Fri Jun 21, 2019 9:28 am
by scottwilkerson
infofedsec wrote:Thank you for your help. You can lock this if you like
great!

Locking