RabbitMQ - Delete Exchange using the REST API

This assumes you have created a RabbitMQ user with the administrator tag.

Refer to the RabbitMQ REST API documentation.

The curl command with the --user option can be used to make an API connection to RabbitMQ. In this example, foo.exchange in virtual host vhost001 will be deleted.

--request DELETE
--user john.doe:itsasecret
--url http://server001:15671/api/exchanges/vhost001/foo.exchange


For the / vhost, use %2F.

--request DELETE
--user john.doe:itsasecret
--url http://server001:15671/api/exchanges/%2f/foo.exchange


If the delete is successfully, no output will be returned. --write-out "%{http_code}" can be included to return the http code. The return code should be 204 (success) or 405 (failed).

~]# curl -X DELETE --write-out "%{http_code}" --user john.doe:itsasecret --url http://server001:15671/api/exchanges/%2f/foo.exchange


Or, on a Linux system, the $? command can be used to determine if the curl command was or was not successful. $? will return 0 if the delete was successful, or 1 if the delete failed.

~]# echo $?


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter c860c in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |