title: Spring Framework RestClientException: Extract String from text/plain response
body: <p>I have a REST API with this endpoint:</p>
  
  <pre><code>@GET
  @Path("rol/{codEmp}")
  @Produces(MediaType.TEXT_PLAIN)
  public String getRole(@PathParam("codEmp") Long codEmp) {
      return dao.getRole(codEmp);
  }
  </code></pre>
  
  <p>An example of response can be: <code>HOUSEKEEPER</code>.</p>
  
  <p>I consume it this way:</p>
  
  <pre><code>@Override
  public String getRole(Long codEmp) {
      HashMap&lt;String, Object&gt; urlVariables = new HashMap&lt;String, Object&gt;();
      urlVariables.put("codEmp", codEmp);
      HttpHeaders httpHeaders = new HttpHeaders();
      httpHeaders.setAccept(Collections.singletonList(MediaType.parseMediaType("text/plain")));
      HttpEntity&lt;Object&gt; requestEntity = new HttpEntity&lt;Object&gt;(httpHeaders);
      return restTemplate.exchange(rootUrl.concat("/rol/{codEmp}"), HttpMethod.GET, requestEntity, String.class, urlVariables).getBody();
  }
  </code></pre>
  
  <p>But I get this error:</p>
  
  <blockquote>
    <p>"Could not extract response: no suitable HttpMessageConverter found
    for response type [java.lang.String] and content type [text/plain]"</p>
  </blockquote>
  
  <p>I know the right way is to send a JSON response but I have to do it with raw String.</p>
  
  <p>How can I solve it?</p>
  
  <p>Thanks</p>