title: Parsing JSON request body with Spring MVC
body: <p>I am using Spring 4.1 framework for developing webservices. When I return a Java object as response, it is automatically converted to JSON and delivered to client, so I assume that JSON parser is in classpath and it is configured properly. However it fails to convert the request body from JSON into Java object and client is getting a HTTP response of 400.</p>
  
  <p>Here is how the webservice looks like:</p>
  
  <pre><code>public class Details{
          public Details(){
  
          }
          int code;
          int area;
      }
  
  @RequestMapping(value = "/api/update/{phoneNumber}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
      public ResponseEntity&lt;String&gt; update(@PathVariable final String phoneNumber, @RequestBody Details details)
  </code></pre>
  
  <p>Here is how the request looks like:</p>
  
  <pre><code>Method: Post
  Content-Type: application/json; charset=utf-8
  Body: {"code":0,"area":12}
  </code></pre>
  
  <p>If I collect the request body as string and parse it manually then it works, so it gets the valid JSON but for some reason it is not parsing it automatically. I have no clue on how to fix it. Please help. Thanks in advance. </p>