title: Resttemplate GET Request with Custom Headers
body: <p>I need to send a GET request with a header: <code>Content-Type: application/camiant-msr-v2.0+xml</code>. I expect an XML response from the server. I tested the request and response with Postman and everything is good. But when I try to do it in Spring with <code>RestTemplate</code>, I always get a 400 bad request. The exceptions from <code>spring</code> are:</p>
  
  <pre><code>Jul 09, 2016 12:53:38 PM org.apache.catalina.core.StandardWrapperValve invoke
  SEVERE: Servlet.service() for servlet [dispatcherServlet] in context with path [/smp] threw exception [Request processing failed; nested exception is org.springframework.web.client.HttpClientErrorException: 400 Bad Request] with root cause
  org.springframework.web.client.HttpClientErrorException: 400 Bad Request
      at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
      at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:641)
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:597)
      at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557)
      at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:475)
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>MultiValueMap&lt;String, String&gt; headers = new LinkedMultiValueMap&lt;String, String&gt;();
  headers.add("Content-Type", "application/camiant-msr-v2.0+xml");
  
  HttpEntity&lt;?&gt; entity = new HttpEntity&lt;Object&gt;(headers);
  log.debug("request headers: " + entity.getHeaders());
  ResponseEntity&lt;String&gt; response = restTemplate.exchange(queryUrl, HttpMethod.GET, entity, String.class);
  </code></pre>
  
  <p>The debug message shows the header as <code>{Content-Type=[application/camiant-msr-v2.0+xml]}</code>, which seems to be correct. I wonder what's wrong with my request and if there's a way to see the requests on the wire to debug.</p>