title: Can pass my own object with RestTemplate PUT
body: <p>I want to build a small RESTful Service, send a PUT request with an Object of a class I created (MyObject), and getting a response with only status.</p>
  
  <p>My controler:</p>
  
  <pre><code>@RestController 
  public class MyControler {
  
  @RequestMapping(path = "/blabla/{id}", method = RequestMethod.PUT)
  @ResponseBody
  public ResponseEntity&lt;String&gt; putMethod (@PathVariable("id") Long id,
                                           @RequestBody MyObject t) {
     /*todo*/
     return new ResponseEntity&lt;String&gt;(HttpStatus.OK);
  }
  </code></pre>
  
  <p>My Test App </p>
  
  <pre><code>@SpringBootApplication
  public class App {
  public String httpPut(String urlStr)  {
    MyObject myObject = new MyObject(p,p,....);
    URI url = null;
    HttpEntity&lt;MyObject&gt; requestEntity;
  
    RestTemplate rest = new RestTemplate();
    rest.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
  
    HttpHeaders headers = new HttpHeaders();
  
    List&lt;MediaType&gt; list = new ArrayList&lt;MediaType&gt;();
    list.add(MediaType.APPLICATION_JSON);
    headers.setAccept(list);
    headers.setContentType(MediaType.APPLICATION_JSON);
    headers.add("Content-Type", "application/json");
  
    requestEntity = new HttpEntity&lt;Transaction&gt;(t, headers);
  
     ResponseEntity&lt;String&gt; response =
                  rest.exchange(url, HttpMethod.PUT, requestEntity, MyObject.class);
  
         return response.getStatusCode().getValue();
  }
  </code></pre>
  
  <p>Im getting an <code>HttpClientErrorException: 400 Bad Request</code>
  Where is my mistake? What I want is for Spring to automaticly serialize the MyObject. MyObject class is implementing serializable. 
  What do I miss?</p>
  
  <p>}</p>