title: org.springframework.web.client.HttpClientErrorException: 401 Unauthorized
body: <p>I have web service URL: </p>
  
  <pre><code>http://myservice.local/aprovalanduser/?format=json&amp;Name=India
  </code></pre>
  
  <p>When I am calling this URL using </p>
  
  <pre class="lang-java prettyprint-override"><code>resttemplate httpsrestTemplate.getForObject(uri, userdetails[].class)
  </code></pre>
  
  <p>I am getting error:</p>
  
  <blockquote>
    <p>org.springframework.web.client.HttpClientErrorException: 401 Unauthorized</p>
  </blockquote>
  
  <p>in the web service method:</p>
  
  <pre><code>method: "GET", 
  data: xmlData, 
  contentType: "application/xml", 
  dataType: "xml", 
  async: true, 
  crossDomain: false,
  </code></pre>
  
  <p>I am setting the header only for XML like below:</p>
  
  <pre class="lang-java prettyprint-override"><code>headers.setContentType(MediaType.APPLICATION_XML);
  </code></pre>