Search code examples
rabbitmqurlencode

How to make RabbitMQ API calls with vhost "/"?


The following API call to RabbitMQ:

http -a USER:PASS localhost:15001/api/queues/

Returns a list of queues:

[
    {
         ...
         "messages_unacknowledged_ram": 0,
         "name": "foo_queue",
         "node": "rabbit@queue-monster-01",
         "policy": "",
         "state": "running",
         "vhost": "/"
     },
     ...
]

Note that the vhost parameter is /.

How do I use a / vhost for the /api/queues/vhost/name call, which returns the details for a specific queue?

I have tried:

  • localhost:15001/api/queues/\//foo_queue
  • localhost:15001/api/queues///foo_queue

But both failed with 404 Object Not Found:

enter image description here


Solution

  • URL Encoding did the trick. The URL should be:

    localhost:15001/api/queues/%2F/foo_queue
                               ⬆⬆⬆
    

    For the record, I think that REST resources should not be named /, especially not by default.