Spring 4 RestController JSON: characteristics not acceptable according to the request “accept” headers

The trick with this error is that it can be very miss-leading. In the situation as with the OP, where you see the error resulting from a browser GET request (with accept header */*), and the proper configuration (in the OPs case a default minimal working configuration) , the cause is very likely the exception while converting to representation.

Here even though the request is not suggesting the representation (Nor parameter, nor path, nor accept header), yet the response is complaining about the

resource identified by this request is only capable of generating
responses with characteristics not acceptable according to the request
“accept” headers

The causes could be:

  • The missing dependencies
  • Error in the return bean
    (e.g. missing getters or the like)

as of Spring Framework 4.1, the minimum jackson version should be 2.1 (2.3 recommended), replace your jackson dependencies with this single one

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.1.2</version>
    </dependency>

One thing that hinders debugging in this case is that in tomcat 7.0.5x versions, this dependency is available in libs, unlike some previous version. So your code works fine in that version of tomcat just as it is

Spring MVC 3.x version should still use the

    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.13</version>
    </dependency>

Leave a Comment