Page 1 of 1

Unable to delete service using curl 'XDELTE' on Nagios XI 5.

Posted: Fri Sep 18, 2020 9:44 am
by rthomas7
This is the command I am trying to use
curl -XDELETE "https://<Nagios XI Host Name>/nagiosxi/api/v1/config/service?apikey=tBNRmsqitghiurFNECXKOu7RjkI6AEOX7p8egoCQKvelfSoSLmCvAB&pretty=1&host_name=testapihost&service_description=Disk Usage on /usr/local&applyconfig=1" -k

Here is the error I get.

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>
Collapse

Could someone help me with this? . I have got 1000+ servers and I need to delete/remove a 'Disk/File system' service

Re: Unable to delete service using curl 'XDELTE' on Nagios X

Posted: Fri Sep 18, 2020 3:38 pm
by mbellerue
It's probably getting hung up because the service_description isn't URL encoded. Try this.

Code: Select all

curl -XDELETE "https://<Nagios XI Host Name>/nagiosxi/api/v1/config/service?apikey=tBNRmsqitghiurFNECXKOu7RjkI6AEOX7p8egoCQKvelfSoSLmCvAB&pretty=1&host_name=testapihost&service_description=Disk%20Usage%20on%20%2Fusr%2Flocal&applyconfig=1" -k
Also, if that does the trick, this site can help out a ton when working with curl and APIs.
https://www.url-encode-decode.com/

Re: Unable to delete service using curl 'XDELTE' on Nagios X

Posted: Tue Sep 22, 2020 6:30 am
by rthomas7
mbellerue wrote:It's probably getting hung up because the service_description isn't URL encoded. Try this.

Code: Select all

curl -XDELETE "https://<Nagios XI Host Name>/nagiosxi/api/v1/config/service?apikey=tBNRmsqitghiurFNECXKOu7RjkI6AEOX7p8egoCQKvelfSoSLmCvAB&pretty=1&host_name=testapihost&service_description=Disk%20Usage%20on%20%2Fusr%2Flocal&applyconfig=1" -k
Also, if that does the trick, this site can help out a ton when working with curl and APIs.
https://www.url-encode-decode.com/

Re: Unable to delete service using curl 'XDELTE' on Nagios X

Posted: Tue Sep 22, 2020 6:34 am
by rthomas7
Thank you very much indeed!. That looks to have done the trick. So, if there is no character or word in the square brackets after "failed", does it mean there was/is no error?

{
"success": "Removed services from the system. Config applied, Nagios Core was restarted.",
"services": [
"testapihost - Disk Usage on \/var\/tmp"
],
"failed": [

]
}

Re: Unable to delete service using curl 'XDELTE' on Nagios X

Posted: Tue Sep 22, 2020 8:09 am
by scottwilkerson
I see there is a ticket with the same issue.

This will be continued in the ticket

Locking thread