Nagios API Put Contact

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
infofedsec
Posts: 32
Joined: Wed Apr 17, 2019 5:28 am

Nagios API Put Contact

Post 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
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Nagios API Put Contact

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
infofedsec
Posts: 32
Joined: Wed Apr 17, 2019 5:28 am

Re: Nagios API Put Contact

Post by infofedsec »

This solved the problem, it updates the contact, I still get "config imported but not applied" when i run the command though
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Nagios API Put Contact

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
infofedsec
Posts: 32
Joined: Wed Apr 17, 2019 5:28 am

Re: Nagios API Put Contact

Post by infofedsec »

Thank you for your help. You can lock this if you like
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Nagios API Put Contact

Post by scottwilkerson »

infofedsec wrote:Thank you for your help. You can lock this if you like
great!

Locking
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked