title: Need help on RestTemplate postForObject() method
body: <p>I have to send JSON data from one service method to the other using <code>postForObject()</code> method.
  I saw one example on <code>RestTemplate</code> on <a href="http://java.dzone.com/articles/how-use-spring-resttemplate-0" rel="noreferrer">this link</a>.</p>
  
  <p><code>postForObject()</code> method has the following format:</p>
  
  <pre><code>User returns = rt.postForObject(uri, u, User.class, vars);
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>User returns = rt.postForObject(uri, u, User.class);
  </code></pre>
  
  <p>I want to know that, after using <code>postForObject()</code> method,  if we implement the service method to accept the <code>User</code> object, how it will look like?</p>
  
  <p>In my project, I have code like<br></p>
  
  <pre><code>RestTemplate restTemplate = new RestTemplate();
  restTemplate.getMessageConverters().add(new MappingJacksonHttpMessageConverter());
  restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
  String uri = "http://testcode.com/myapp/api/launchservices";
  ServiceRequest request = new ServiceRequest();
  request.setId(UUID.randomUUID().toString());
  ....
  </code></pre>
  
  <p>I am getting error at this line:</p>
  
  <pre><code>ServiceRequest req = restTemplate.postForObject(uri, request, ServiceRequest.class);
  </code></pre>
  
  <p>while executing this, I am getting this error mesage:</p>
  
  <pre><code>org.springframework.web.client.HttpClientErrorException: 400 Bad Request
      at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:88)
      at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:537)
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:493)
      at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:452)
      at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:302)
  </code></pre>
  
  <p>my implementation method is:</p>
  
  <pre><code>@RequestMapping(value = "/launchservices", method = RequestMethod.POST)
  @ResponseBody
  public boolean launchServices(@PathVariable ServiceRequest request) {
      System.out.println("Request: "+request.toString());
      return true;
  }
  </code></pre>
  
  <p>How to get rid of this? What will be the URI?</p>