RabbitMQ - Publish Message 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, John Doe publishes message "Hello World" to exchange001 with routing key key001.

--request POST 
--user john.doe:itsasecret 
--data '{"properties":{},"routing_key":"key001","payload":"Hello World","payload_encoding":"string"}'  


Or a JSON file can be created. Let's say foo.json contains the following.

  "payload":"Hello World",


Then the following command can be used.

--request POST 
--user john.doe:itsasecret 
--data @foo.json  


If the message is successfully published, something like this should be returned.



If the message fails to publish, which can occur if the bad routing key is used, something like this should be returned.



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 50178 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   |