Announcement Announcement Module
Collapse
No announcement yet.
Is "application/*+json" a valid media type? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is "application/*+json" a valid media type?

    I'm using a RestTemplate to get a Jackson object as follows:

    Code:
    MyClass object = restOperations.getForObject(myUrl, MyClass.class);
    The server is returning a 400 (Bad Request) code. I've traced it to the following Accept header in the request:

    Code:
    application/json, application/*+json
    If instead I call restOperations.execute() and (in the RequestCallback) set the Accept header to simply:

    Code:
    application/json
    ... then the request succeeds and RestTemplate returns the correct object. The presence of the media type "application/*+json" is causing the 400 error. I've verified this by adding/removing it to the same request when sent from POSTman.

    The problematic media type is added by this constructor:

    Code:
        public MappingJacksonHttpMessageConverter() {
            super(new MediaType("application", "json", DEFAULT_CHARSET), new MediaType("application", "*+json", DEFAULT_CHARSET));
        }
    So, two questions:

    1. Is "application/*+json" a valid media type, meaning the web server is wrongly returning a 400?
    2. Given that I probably can't change the web server, is there a way to configure MappingJacksonHttpMessageConverter to not add this media type alongside the basic "application/json" one?

    Thanks for any help.
Working...
X