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
Unable to delete service using curl 'XDELTE' on Nagios xi 5.
-
- Posts: 5
- Joined: Thu Mar 07, 2019 7:13 am
-
- Posts: 1403
- Joined: Fri Jul 12, 2019 11:10 am
Re: Unable to delete service using curl 'XDELTE' on Nagios X
It's probably getting hung up because the service_description isn't URL encoded. Try this.
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/
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
https://www.url-encode-decode.com/
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
- Posts: 5
- Joined: Thu Mar 07, 2019 7:13 am
Re: Unable to delete service using curl 'XDELTE' on Nagios X
mbellerue wrote:It's probably getting hung up because the service_description isn't URL encoded. Try this.
Also, if that does the trick, this site can help out a ton when working with curl and APIs.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
https://www.url-encode-decode.com/
-
- Posts: 5
- Joined: Thu Mar 07, 2019 7:13 am
Re: Unable to delete service using curl 'XDELTE' on Nagios X
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": [
]
}
{
"success": "Removed services from the system. Config applied, Nagios Core was restarted.",
"services": [
"testapihost - Disk Usage on \/var\/tmp"
],
"failed": [
]
}
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
Re: Unable to delete service using curl 'XDELTE' on Nagios X
I see there is a ticket with the same issue.
This will be continued in the ticket
Locking thread
This will be continued in the ticket
Locking thread