So I was testing my code with MockMvc and spring-webmvc 6.0.4.

My tests kept failing with "org.springframework.web.HttpMediaTypeNotSupportedException: Content-Type 'application/json;charset=UTF-8' is not supported" which was very odd considering that my controller does indeed support that.

Turns out it was a missing message converter.

The related throw is in AbstractMessageConverterMethodArgumentResolver line 144.

Wouldn't it be better if some other exception was thrown here to point the user into the direction of not the formal declaration of content types being the problem but the lack of message conversion?

Comment From: rstoyanchev

UNSUPPORTED_MEDIA_TYPE (415) is a standard response for when the server can't read a specific content type. It does not mean the problem is with the user or the server, and it could be either.

There is actually no way for us to know if it is a missing converter due to a configuration error, or a content type that isn't expected. All we know is that with the configured converters we don't support the given media type.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.