415 Unsupported Media Type issue

216 views
Skip to first unread message

kai.hac...@nzqa.govt.nz

unread,
Sep 13, 2018, 10:25:53 PM9/13/18
to rabbitmq-users

In the code I inherited there is a REST call that sets up user permissions for a virtual host in a rabbitmq installation. On my developer box I have latest RabbitMQ server installed, 3.7.7. The client software uses a Spring RestTemplate to query the host. It generates a PUT request to http://localhost:15672/api/permissions/myhost/administrator with a payload of

{"read":".*","write":".*","configure":".*"}

and an HTTP header Content-Type:application/json;charset=UTF-8

This all looks reasonable to me - but the response is

HTTP/1.1 415 Unsupported Media Type

This code is years old, and I suspect it is my RabbitMQ installation that is too new for it, but I'd like to rather make the code future-proof than to install an RabbitMQ from 2015 ...

I have googled extensively on this issue but all I found was some bug about doubled headers in the rabbitmq client software that is not in use here. I traced it into apache httpclient classes and there is nothing on the sender side that smells.

Any suggestions what is wrong?

Michael Klishin

unread,
Sep 14, 2018, 11:47:27 AM9/14/18
to rabbitm...@googlegroups.com
We had something similar in the early years of Hop [1] but I don't remember the specifics.

Just use Hop instead of reinventing it.


--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Kai Hackemesser

unread,
Sep 16, 2018, 5:11:17 PM9/16/18
to rabbitm...@googlegroups.com

The suggestion is absolutely valid, although I would have to file a change request first, get approval to change the code, get it into sprint backlog. I need a solution that I can apply yesterday without to fight buerocratic trolls…

 

From: rabbitm...@googlegroups.com <rabbitm...@googlegroups.com> On Behalf Of Michael Klishin
Sent: 15 September, 2018 3:47
To: rabbitm...@googlegroups.com
Subject: Re: [rabbitmq-users] 415 Unsupported Media Type issue

 

We had something similar in the early years of Hop [1] but I don't remember the specifics.

 

Just use Hop instead of reinventing it.

 

On Fri, Sep 14, 2018 at 4:25 AM, <kai.hac...@nzqa.govt.nz> wrote:

In the code I inherited there is a REST call that sets up user permissions for a virtual host in a rabbitmq installation. On my developer box I have latest RabbitMQ server installed, 3.7.7. The client software uses a Spring RestTemplate to query the host. It generates a PUT request to http://localhost:15672/api/permissions/myhost/administrator with a payload of

{"read":".*","write":".*","configure":".*"}

and an HTTP header Content-Type:application/json;charset=UTF-8

This all looks reasonable to me - but the response is

HTTP/1.1 415 Unsupported Media Type

This code is years old, and I suspect it is my RabbitMQ installation that is too new for it, but I'd like to rather make the code future-proof than to install an RabbitMQ from 2015 ...

I have googled extensively on this issue but all I found was some bug about doubled headers in the rabbitmq client software that is not in use here. I traced it into apache httpclient classes and there is nothing on the sender side that smells.

Any suggestions what is 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 rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.




--

MK

 

Staff Software Engineer, Pivotal/RabbitMQ

--

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.
To post to this group, send email to rabbitm...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

 

Tell us what you think.

NZQA would like your feedback on the service we provide so that we can improve the way we work with you.

Please use this link to complete our anonymous customer satisfaction survey.

 

********************************************************************************
This email may contain legally privileged information and is intended only for the addressee. It is not necessarily the official view or
communication of the New Zealand Qualifications Authority. If you are not the intended recipient you must not use, disclose, copy or distribute this email or
information in it. If you have received this email in error, please contact the sender immediately. NZQA does not accept any liability for changes made to this email or attachments after sending by NZQA.

All emails have been scanned for viruses and content by MailMarshal.
NZQA reserves the right to monitor all email communications through its network.

********************************************************************************

Kai Hackemesser

unread,
Sep 16, 2018, 5:20:23 PM9/16/18
to rabbitm...@googlegroups.com

For curiosity reasons I checked the project out and this is what the API documentation says about the administrative requests:

Managing Users

TBD

Managing Permissions

TBD

This would not get me very far even if I would apply a migration below the radar…

 

From: rabbitm...@googlegroups.com <rabbitm...@googlegroups.com> On Behalf Of Michael Klishin
Sent: 15 September, 2018 3:47
To: rabbitm...@googlegroups.com
Subject: Re: [rabbitmq-users] 415 Unsupported Media Type issue

 

We had something similar in the early years of Hop [1] but I don't remember the specifics.

 

Just use Hop instead of reinventing it.

 

On Fri, Sep 14, 2018 at 4:25 AM, <kai.hac...@nzqa.govt.nz> wrote:

In the code I inherited there is a REST call that sets up user permissions for a virtual host in a rabbitmq installation. On my developer box I have latest RabbitMQ server installed, 3.7.7. The client software uses a Spring RestTemplate to query the host. It generates a PUT request to http://localhost:15672/api/permissions/myhost/administrator with a payload of

{"read":".*","write":".*","configure":".*"}

and an HTTP header Content-Type:application/json;charset=UTF-8

This all looks reasonable to me - but the response is

HTTP/1.1 415 Unsupported Media Type

This code is years old, and I suspect it is my RabbitMQ installation that is too new for it, but I'd like to rather make the code future-proof than to install an RabbitMQ from 2015 ...

I have googled extensively on this issue but all I found was some bug about doubled headers in the rabbitmq client software that is not in use here. I traced it into apache httpclient classes and there is nothing on the sender side that smells.

Any suggestions what is 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 rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.




--

MK

 

Staff Software Engineer, Pivotal/RabbitMQ

--

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.
To post to this group, send email to rabbitm...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

 

Tell us what you think.

Michael Klishin

unread,
Sep 16, 2018, 6:48:36 PM9/16/18
to rabbitm...@googlegroups.com
I'm really sorry you need to get an approval to avoid reinventing the wheel.

I'd still *highly* recommend learning from Hop and its test suite [1]. It is open source software
and you are welcome to inspect what it does to set up the HTTP request machinery (and contribute the docs or anything else you find missing).


On Sun, Sep 16, 2018 at 11:11 PM, Kai Hackemesser <Kai.Hac...@nzqa.govt.nz> wrote:

The suggestion is absolutely valid, although I would have to file a change request first, get approval to change the code, get it into sprint backlog. I need a solution that I can apply yesterday without to fight buerocratic trolls…

 

From: rabbitmq-users@googlegroups.com <rabbitmq-users@googlegroups.com> On Behalf Of Michael Klishin
Sent: 15 September, 2018 3:47
To: rabbitmq-users@googlegroups.com
Subject: Re: [rabbitmq-users] 415 Unsupported Media Type issue

 

We had something similar in the early years of Hop [1] but I don't remember the specifics.

 

Just use Hop instead of reinventing it.

 

On Fri, Sep 14, 2018 at 4:25 AM, <kai.hac...@nzqa.govt.nz> wrote:

In the code I inherited there is a REST call that sets up user permissions for a virtual host in a rabbitmq installation. On my developer box I have latest RabbitMQ server installed, 3.7.7. The client software uses a Spring RestTemplate to query the host. It generates a PUT request to http://localhost:15672/api/permissions/myhost/administrator with a payload of

{"read":".*","write":".*","configure":".*"}

and an HTTP header Content-Type:application/json;charset=UTF-8

This all looks reasonable to me - but the response is

HTTP/1.1 415 Unsupported Media Type

This code is years old, and I suspect it is my RabbitMQ installation that is too new for it, but I'd like to rather make the code future-proof than to install an RabbitMQ from 2015 ...

I have googled extensively on this issue but all I found was some bug about doubled headers in the rabbitmq client software that is not in use here. I traced it into apache httpclient classes and there is nothing on the sender side that smells.

Any suggestions what is 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 rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.




--

MK

 

Staff Software Engineer, Pivotal/RabbitMQ

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

 

Tell us what you think.

NZQA would like your feedback on the service we provide so that we can improve the way we work with you.

Please use this link to complete our anonymous customer satisfaction survey.

 

********************************************************************************
This email may contain legally privileged information and is intended only for the addressee. It is not necessarily the official view or
communication of the New Zealand Qualifications Authority. If you are not the intended recipient you must not use, disclose, copy or distribute this email or
information in it. If you have received this email in error, please contact the sender immediately. NZQA does not accept any liability for changes made to this email or attachments after sending by NZQA.

All emails have been scanned for viruses and content by MailMarshal.
NZQA reserves the right to monitor all email communications through its network.

********************************************************************************

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Luke Bakken

unread,
Sep 17, 2018, 9:53:53 AM9/17/18
to rabbitmq-users
Hello,

Please provide the entire HTTP request and response, or do a TCP capture and provide that. A few lines of output isn't informative.

Thanks -
Luke

kai.hac...@nzqa.govt.nz

unread,
Sep 17, 2018, 8:11:36 PM9/17/18
to rabbitmq-users
Hi, Luke, 

I tried hard but was not able to provide a TCP capture (my local developer box is behind a firewall, accessing 127.0.0.1 bypasses wireshark, but accessing my ethernet interface IP address is failing to establish a connection and so no PUT request is logged...)
What I was seeing was that when I simulated the same call with curl, copied the URL from the debug session right at the moment HttpClient would execute the request, and copied the headers and json payload from the request body, that the response was a 204 instead of 415, so technically it should have worked from within the RestTemplate call. If I would have been able to tcp trace it, I would probably have seen any diversion intransparent to me.

Luke Bakken

unread,
Sep 17, 2018, 8:20:20 PM9/17/18
to rabbitmq-users
Hello,

Thanks for that information, it seems to show that the problem is with the RestTemplate / HttpClient code and not RabbitMQ.

Any chance you can share the code that makes the REST call?

I am not experienced at all with RestTemplate but it appears that using setContentType with MediaType.APPLICATION_JSON is necessary rather than constructing your own custom headers.

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);

HttpEntity<String> entity = new HttpEntity<String>(requestJson, headers);
ResponseEntity<String> response = restTemplate.put(url, entity);


Maybe this will help but it's just basically a guess.

Thanks!
Luke

kai.hac...@nzqa.govt.nz

unread,
Sep 17, 2018, 9:44:35 PM9/17/18
to rabbitmq-users
On the client side there is the Apache HttpClient involved (wrapped in a spring component), the http entity is a java class that gets deserialized by Jackson API, which also sets automatically the http content-type header ("application/json;charset=UTF-8"). This header is internally set in their MappingJackson2HttpMessageConverter .
I traced the headers until touching the lowest layer in HttpClient where it creates a connection and sends the headers, then the payload. 

I traced the Rest call a bit deeper and was also able to trace TCP against the sandbox V3.5.x installation, and it is interestingly the know double content-type issue. I will find out what caused that now.

Michael Klishin

unread,
Sep 18, 2018, 3:34:20 AM9/18/18
to rabbitm...@googlegroups.com
Please, please, please just use Hop as an example instead of reinventing it independently. It uses exactly the same
set of libraries (Spring parts, Jackson, Apache HTTP Components) and used to have this problem in early development days.

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

kai.hac...@nzqa.govt.nz

unread,
Sep 19, 2018, 6:01:00 PM9/19/18
to rabbitmq-users
Good news, I convinced our middleware team that mitigation of our technical debt is necessary, and they will put it on the backlog. With a bit of luck it will be in our first 2019 release... 
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages