title: Spring rest service not returning body
body: <p>I have one rest service with following implementation - </p>
  
  <pre><code>    @RequestMapping(method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE)
      @ResponseBody
      @JsonSerialize
      public ResponseEntity&lt;String&gt; handleData(HttpMethod method, HttpServletRequest httpRequest)
              throws URISyntaxException, IOException {
  
          BackendRequest request = new BackendRequest();
          request.setHttpRequest(httpRequest);
          request.setMethod(method);
  
          BackendResponse backendResponse = service.getresponse(request);
          ResponseEntity&lt;String&gt; response = backendResponse.getResponse();
          return new ResponseEntity&lt;String&gt;(response.getBody(), response.getHeaders(), response.getStatusCode());
          // return response;
  
      }
  </code></pre>
  
  <p>I am getting all the headers and response status correctly but I am not getting the json response. What is wrong here?</p>
  
  <p>I am trying to do following - 
  <a href="https://stackoverflow.com/a/23736527/2197994">https://stackoverflow.com/a/23736527/2197994</a></p>
  
  <p>Somewhere deep inside the nested calls, I am getting the response from some other backend using spring rest template.</p>
  
  <pre><code>public BackendResponse callBackend(BackendRequest request) throws URISyntaxException, IOException {
  
          String body = null;
          ResponseEntity&lt;String&gt; responseEntity = null;
          URI uri = new URI("http", null, "localhost", 8080, request.getRequestURL(), request.getQueryString(), null);
  
          MultiValueMap&lt;String, String&gt; requestHeaders = getHeadersInfo(request.getHttpRequest());
  
          if (HttpMethod.POST.equals(request.getMethod())) {
              body = request.getHttpRequest().getReader().lines().collect(Collectors.joining(System.lineSeparator()));
              responseEntity = restTemplate.exchange(uri, request.getMethod(),
                      new HttpEntity&lt;String&gt;(body, requestHeaders), String.class);
  
          } else if (HttpMethod.GET.equals(request.getMethod())) {
              responseEntity = restTemplate.exchange(uri, request.getMethod(),
                      new HttpEntity&lt;String&gt;(body, requestHeaders), String.class);
          } else {
              LOG.warn("Method:{} not supported yet", request.getMethod());
          }
  
          BackendResponse response = new BackendResponse();
          response.setResponse(responseEntity);
          return response;
  
      }
  </code></pre>