Getting HTTP/1.1 401 Unauthorized while executing api

1,339 views
Skip to first unread message

Ankit Vasava

unread,
Oct 26, 2019, 7:35:30 AM10/26/19
to rabbitmq-users
Hello All,
It's successfully installed and working fine
Now need to used rabbitMq api url mentioned below,


when I have executed get queue value api mentioned below.

curl -i -u guest:guest -X POST -H "Content-Type: application/json"  -d '{"count":5,"requeue":true,"encoding":"auto","truncate":50000}' http://localhost:15672/api/queues/vhost/conf/get
HTTP/1.1 401 Unauthorized
server: Cowboy
date: Sat, 26 Oct 2019 11:19:54 GMT
content-length: 53
vary: accept, accept-encoding, origin
content-type: application/json

{"error":"not_authorised","reason":"Access refused."}

It's give me 401 Unauthorized

I have checked guest user permission it's full but still i m getting from my linux console that error ,

can yo please guide me where i am wrong.


Wesley Peng

unread,
Oct 26, 2019, 7:50:45 AM10/26/19
to 'Biswajit Rout' via rabbitmq-users
Should you specify vhost with a special name in the request? 

regards 
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.

Ankit Vasava

unread,
Oct 26, 2019, 7:52:54 AM10/26/19
to rabbitmq-users
Yes,

my virtualhost= "/" so 

can you please guide me


On Saturday, October 26, 2019 at 5:20:45 PM UTC+5:30, Wesley Peng wrote:
Should you specify vhost with a special name in the request? 

regards 

On Sat, Oct 26, 2019, at 7:35 PM, Ankit Vasava wrote:
Hello All,
It's successfully installed and working fine
Now need to used rabbitMq api url mentioned below,


when I have executed get queue value api mentioned below.

curl -i -u guest:guest -X POST -H "Content-Type: application/json"  -d '{"count":5,"requeue":true,"encoding":"auto","truncate":50000}' http://localhost:15672/api/queues/vhost/conf/get
HTTP/1.1 401 Unauthorized
server: Cowboy
date: Sat, 26 Oct 2019 11:19:54 GMT
content-length: 53
vary: accept, accept-encoding, origin
content-type: application/json

{"error":"not_authorised","reason":"Access refused."}

It's give me 401 Unauthorized

I have checked guest user permission it's full but still i m getting from my linux console that error ,

can yo please guide me where i am wrong.



--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitm...@googlegroups.com.

Wesley Peng

unread,
Oct 26, 2019, 7:57:21 AM10/26/19
to 'Biswajit Rout' via rabbitmq-users
Hi

use this vhost in the request please. 
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.

Ankit Vasava

unread,
Oct 26, 2019, 8:00:34 AM10/26/19
to rabbitmq-users

I have tried like this

curl -i -u guest:guest -X POST -H "Content-Type: application/json"  -d '{"count":5,"requeue":true,"encoding":"auto","truncate":50000}' http://localhost:15672/api/queues///conf/get

but it's given me same response 401

Wesley Peng

unread,
Oct 26, 2019, 8:09:07 AM10/26/19
to 'Biswajit Rout' via rabbitmq-users
Replace / with \/
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.

Ankit Vasava

unread,
Oct 26, 2019, 8:16:53 AM10/26/19
to rabbitmq-users
again same see below reponse


curl -i -u guest:guest -X POST -H "Content-Type: application/json"  -d '{"count":5,"requeue":true,"encoding":"auto","truncate":50000}' http://localhost:15672/api/queues/V/conf/get
HTTP/1.1 401 Unauthorized
server: Cowboy
date: Sat, 26 Oct 2019 12:15:34 GMT
content-length: 53
vary: accept, accept-encoding, origin
content-type: application/json

{"error":"not_authorised","reason":"Access refused."}


Wesley Peng

unread,
Oct 26, 2019, 8:19:17 AM10/26/19
to 'Biswajit Rout' via rabbitmq-users
Not V, it’s \/ for url escape.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.

Ankit Vasava

unread,
Oct 26, 2019, 8:23:31 AM10/26/19
to rabbitmq-users
again same

see response below.

 curl -i -u guest:guest -X POST -H "Content-Type: application/json"  -d '{"count":5,"requeue":true,"encoding":"auto","truncate":50000}' http://localhost:15672/api/queues/\/conf/get
HTTP/1.1 401 Unauthorized
server: Cowboy
date: Sat, 26 Oct 2019 12:20:53 GMT
content-length: 53
vary: accept, accept-encoding, origin
content-type: application/json

{"error":"not_authorised","reason":"Access refused."}

curl -i -u guest:guest -X POST -H "Content-Type: application/json"  -d '{"count":5,"requeue":true,"encoding":"auto","truncate":50000}' http://localhost:15672/api/queues/\//conf/get
HTTP/1.1 405 Method Not Allowed
server: Cowboy
date: Sat, 26 Oct 2019 12:20:21 GMT
content-length: 0
allow: HEAD, GET, OPTIONS

Wesley Peng

unread,
Oct 26, 2019, 8:28:39 AM10/26/19
to 'Biswajit Rout' via rabbitmq-users
Ok please check the backend logs to dig out more. 
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.

Lutz Horn

unread,
Oct 26, 2019, 8:31:30 AM10/26/19
to rabbitm...@googlegroups.com
Use .../\//...

You must escape the single / so that it becomes a segment of the path.

Von: Ankit Vasava
Gesendet: ‎26.‎10.‎2019 14:23
An: rabbitmq-users
Betreff: Re: [rabbitmq-users] Getting HTTP/1.1 401 Unauthorized whileexecuting api

To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/127ce21c-4172-4fde-9c0d-c6a70fc87030%40googlegroups.com.

Ankit Vasava

unread,
Oct 26, 2019, 8:36:32 AM10/26/19
to rabbitmq-users
i have tried this

but see below response.

 curl -i -u guest:guest -X POST -H "Content-Type: application/json"  -d '{"count":5,"requeue":true,"encoding":"auto","truncate":50000}' http://localhost:15672/api/queues/\//conf/get
HTTP/1.1 405 Method Not Allowed
server: Cowboy
date: Sat, 26 Oct 2019 12:34:54 GMT
content-length: 0
allow: HEAD, GET, OPTIONS


Ankit Vasava

unread,
Oct 26, 2019, 8:37:49 AM10/26/19
to rabbitmq-users
There is no info coming into logs when execute api.

my log path

tail -f /var/log/rabbitmq/rab...@localhost.log

Luke Bakken

unread,
Oct 28, 2019, 2:54:49 PM10/28/19
to rabbitmq-users
Hi Ankit,

This is the correct request. Note that the / vhost is encoded as %2F:

curl -i -u guest:guest -X POST -H "Content-Type: application/json" -d '{"count":5,"requeue":true,"encoding":"auto","truncate":50000}' http://localhost:15672/api/queues/%2F/conf/get

https://rawcdn.githack.com/rabbitmq/rabbitmq-management/v3.8.0/priv/www/api/index.html

From the above documentation:

Many URIs require the name of a virtual host as part of the path, since names only uniquely identify objects within a virtual host. As the default virtual host is called "/", this will need to be encoded as "%2F".

Thanks,
Luke


On Saturday, October 26, 2019 at 5:36:32 AM UTC-7, Ankit Vasava wrote:
Reply all
Reply to author
Forward
0 new messages