Bootstrap FreeKB - RabbitMQ - Create Binding using the REST API
RabbitMQ - Create Binding using the REST API

Updated:   |  RabbitMQ articles

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, John Doe will make a connection to the RabbitMQ server listening on port 15671 and then create a direct exchange named foo.exchange.

curl
--request POST
--user john.doe:itsasecret
--url http://hostname:15671/api/exchanges/vhost001/foo.exchange
--header 'content-type: application/json'
--data '{ "routing_key": "foo.key" }'
--write-out "%{http_code}"

 

For the / vhost, use %2F

curl
--request POST
--user john.doe:itsasecret
--url http://hostname:15671/api/exchanges/%2f/foo.exchange
--header 'content-type: application/json'
--data '{ "routing_key": "foo.key" }'
--write-out "%{http_code}"

 

No output will be returned, regardless if the exchange is or is not created. For this reason, the -w or --write-out option is included to get the return code of the curl command.




Did you find this article helpful?

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



Comments


Add a Comment


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