Krishna murthy
Krishna murthy

Reputation: 191

How to delete a connection using curl and HTTP API in RabbitMQ

It is given in the HTTP API documentation of RabbitMQ that /api/connections/name can be used to delete connection. But curl -i -u guest:guest -X "DELETE" http://localhost:15672/api/connections/ --data-urlencode "${conn_name}" gives:

HTTP/1.1 405 Method Not Allowed
allow: HEAD, GET, OPTIONS
content-length: 0
date: Wed, 12 Dec 2018 16:54:48 GMT
server: Cowboy
vary: origin

However GET is working. curl -i -u guest:guest -X GET http://localhost:15672/api/connections/ --data-urlencode "${conn_name}" gives

HTTP/1.1 200 OK
cache-control: no-cache
content-length: 1175
content-type: application/json
date: Wed, 12 Dec 2018 16:48:32 GMT
server: Cowboy
vary: accept, accept-encoding, origin

[{"auth_mechanism":"PLAIN",...

Upvotes: 0

Views: 1114

Answers (1)

Luke Bakken
Luke Bakken

Reputation: 9627

Please carefully re-read the API documentation for /api/connections and DELETE. You will notice that the correct URI for this operation is /api/connections/name, where name is the name of your connection. The --data-urlencode option for curl is mainly for POST requests (but see the -G curl option). Your GET request is actually returning all connections.

So, if your connection name is "My RabbitMQ Connection", you will first have to URL-encode it, and create the correct URI:

curl -4vvvu guest:guest -X DELETE 'localhost:15672/api/connections/My%20RabbitMQ%20Connection'

Upvotes: 3

Related Questions