title: resttemplate getForObject map responsetype
body: <p><strong><em>Update 02/05/2018 (about 4 years later)...I tested this again as people have been upvoting my question/answer and Sotirios Delimanolis is correct that I should not have to write the code in my answer to make this work. I used basically the same RestTemplate/REST service setup as shown in my question with the REST service having a confirmed response content type of application/json and RestTemplate was able to process the response with no issues into a Map.</em></strong></p>
  
  <hr>
  
  <p>I'm invoking a rest service that returns <code>JSON</code> like this:</p>
  
  <pre><code>{
     "some.key" : "some value",
     "another.key" : "another value"
  }
  </code></pre>
  
  <p>I would like to think that I can invoke this service with a <code>java.util.Map</code> as the response type but that's not working for me.  I get this exception:</p>
  
  <pre><code>org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [interface java.util.Map]
  </code></pre>
  
  <p>Should I just specify <code>String</code> as the response type and convert the <code>JSON</code> to a <code>Map</code>? </p>
  
  <p><b>Edit I</b></p>
  
  <p>Here's my restTemplate call:</p>
  
  <pre><code>private Map&lt;String, String&gt; getBuildInfo(String buildUrl) {
      return restTemplate.getForObject(buildUrl, Map.class);
  }
  </code></pre>
  
  <p>Here's how I'm setting up the restTemplate:</p>
  
  <pre><code>@PostConstruct
  public void initialize() {
      List&lt;ClientHttpRequestInterceptor&gt; interceptors = new ArrayList&lt;&gt;();
      interceptors.add(new ClientHttpRequestInterceptor() {
          @Override
          public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
              HttpRequestWrapper requestWrapper = new HttpRequestWrapper(request);
              requestWrapper.getHeaders().setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
              return execution.execute(requestWrapper, body);
          }
      });
      restTemplate.setInterceptors(interceptors);
  }
  </code></pre>
  
  <p><b>Edit II</b></p>
  
  <p>Full error message:</p>
  
  <pre><code>org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [interface java.util.Map] and content type [application/octet-stream]
      at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:108) ~[spring-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:549) ~[spring-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
      at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:502) ~[spring-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
      at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:239) ~[spring-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
      at idexx.ordering.services.AwsServersServiceImpl.getBuildInfo(AwsServersServiceImpl.java:96) ~[classes/:na]
  </code></pre>