title: Spring RestTemplate to POST request with Custom Headers and a Request Object
body: <p>In Spring RestTemplate is there a way to send Custom Headers together with a POST Request Object. I have already tried out the <code>exchange</code> method which is available. It seems that we can send key value pairs together with a custom headers but not a request object itself attached to the <code>HttpEntity.</code> The following code illustrates the attempt and it seems to be <code>400 BadRequest</code> for the server. </p>
  
  <pre><code>    HttpHeaders requestHeaders = new HttpHeaders();
      requestHeaders.setContentType(MediaType.APPLICATION_JSON);
  
      HttpEntity&lt;?&gt; httpEntity = new HttpEntity&lt;Object&gt;(requestDTO, requestHeaders);
  
      RestTemplate restTemplate = new RestTemplate();
      restTemplate.exchange(URL, HttpMethod.POST, httpEntity, SomeObject.class);
  </code></pre>
  
  <p>Anyone aware about this situation ? Or is it something which is not possible that Im trying to do ?</p>