{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2200","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2200/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2200/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2200/events","html_url":"https://github.com/spring-projects/spring-boot/issues/2200","id":52411179,"number":2200,"title":"RestTemplate response body null if I switch from Boot 1.1.9 to 1.2.0","user":{"login":"khoubyari","id":1657168,"avatar_url":"https://avatars.githubusercontent.com/u/1657168?v=3","gravatar_id":"","url":"https://api.github.com/users/khoubyari","html_url":"https://github.com/khoubyari","followers_url":"https://api.github.com/users/khoubyari/followers","following_url":"https://api.github.com/users/khoubyari/following{/other_user}","gists_url":"https://api.github.com/users/khoubyari/gists{/gist_id}","starred_url":"https://api.github.com/users/khoubyari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khoubyari/subscriptions","organizations_url":"https://api.github.com/users/khoubyari/orgs","repos_url":"https://api.github.com/users/khoubyari/repos","events_url":"https://api.github.com/users/khoubyari/events{/privacy}","received_events_url":"https://api.github.com/users/khoubyari/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/spring-projects/spring-boot/labels/waiting-for-feedback","name":"waiting-for-feedback","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-12-18T20:17:12Z","updated_at":"2015-01-19T18:46:50Z","closed_at":null,"body":"Hi,\r\n\r\nI have simple REST client code that was working with 1.1.x but when I switch to 1.2 the response body becomes null! \r\n\r\n```java\r\nResponseEntity<String> response =  new RestTemplate().exchange(someURL, HttpMethod.GET, someStringEntity, String.class);\r\n// response comes back with status code 200 and all the correct headers but response.getBody() returns null\r\n```\r\nIf I switch back to Spring Boot 1.1.9 then the body is not null and has the correct JSON string.\r\nMy POM dependencies look like this (my application is packaged as a war with embedded Tomcat)\r\n\r\n```xml\r\n\r\n    <parent>\r\n        <groupId>org.springframework.boot</groupId>\r\n        <artifactId>spring-boot-starter-parent</artifactId>\r\n        <version>1.2.0.RELEASE</version>\r\n    </parent>\r\n\r\n    <dependencies>\r\n\r\n        <dependency> <!-- custom logging library; uses GSON -->\r\n            <groupId>com.sample</groupId>\r\n            <artifactId>custom-logging-lib</artifactId>\r\n            <version>0.0.2-SNAPSHOT</version>\r\n        </dependency>\r\n        <dependency>\r\n            <groupId>com.google.code.gson</groupId>\r\n            <artifactId>gson</artifactId>\r\n            <version>2.3.1</version>\r\n        </dependency>\r\n\r\n        <dependency>\r\n            <groupId>org.springframework.boot</groupId>\r\n            <artifactId>spring-boot-actuator</artifactId>\r\n        </dependency>\r\n\r\n        <dependency>\r\n            <groupId>org.springframework.boot</groupId>\r\n            <artifactId>spring-boot-starter-web</artifactId>\r\n        </dependency>\r\n\r\n        <dependency>\r\n            <groupId>org.springframework.boot</groupId>\r\n            <artifactId>spring-boot-starter-security</artifactId>\r\n        </dependency>\r\n\r\n        <dependency>\r\n            <groupId>org.springframework.boot</groupId>\r\n            <artifactId>spring-boot-starter-tomcat</artifactId>\r\n            <scope>provided</scope>\r\n        </dependency>\r\n\r\n        <dependency>\r\n            <groupId>org.springframework.boot</groupId>\r\n            <artifactId>spring-boot-starter-data-jpa</artifactId>\r\n        </dependency>\r\n\r\n        <dependency>\r\n            <groupId>com.h2database</groupId>\r\n            <artifactId>h2</artifactId>\r\n            <version>1.4.180</version>\r\n        </dependency>\r\n\r\n        <dependency>\r\n            <groupId>com.fasterxml.jackson.core</groupId>\r\n            <artifactId>jackson-databind</artifactId>\r\n        </dependency>\r\n\r\n        <dependency>  <!-- these are needed for some custom marshalling in the app -->\r\n            <groupId>com.fasterxml.jackson.datatype</groupId>\r\n            <artifactId>jackson-datatype-jdk8</artifactId>\r\n            <version>2.4.4</version>\r\n        </dependency>\r\n        <dependency>\r\n            <groupId>com.fasterxml.jackson.datatype</groupId>\r\n            <artifactId>jackson-datatype-jsr310</artifactId>\r\n            <version>2.4.4</version>\r\n        </dependency>\r\n\r\n        <dependency>\r\n            <groupId>com.mangofactory</groupId>\r\n            <artifactId>swagger-springmvc</artifactId>\r\n            <version>0.8.5</version>\r\n        </dependency>\r\n        <dependency>\r\n            <groupId>org.ajar</groupId>\r\n            <artifactId>swagger-spring-mvc-ui</artifactId>\r\n            <version>0.2</version>\r\n        </dependency>\r\n\r\n        <dependency>\r\n            <groupId>org.hsqldb</groupId>\r\n            <artifactId>hsqldb</artifactId>\r\n            <scope>runtime</scope>\r\n        </dependency>\r\n\r\n        <dependency>\r\n            <groupId>org.springframework.boot</groupId>\r\n            <artifactId>spring-boot-starter-test</artifactId>\r\n            <scope>test</scope>\r\n        </dependency>\r\n\r\n        <dependency>\r\n            <groupId>com.jayway.jsonpath</groupId>\r\n            <artifactId>json-path</artifactId>\r\n            <version>0.9.1</version>\r\n            <scope>test</scope>\r\n        </dependency>\r\n        <dependency>\r\n            <groupId>com.jayway.jsonpath</groupId>\r\n            <artifactId>json-path-assert</artifactId>\r\n            <version>0.9.1</version>\r\n            <scope>test</scope>\r\n        </dependency>\r\n\r\n        <dependency>\r\n            <groupId>org.codehaus.jackson</groupId>\r\n            <artifactId>jackson-core-asl</artifactId>\r\n            <version>1.9.13</version>\r\n        </dependency>\r\n\r\n        <dependency>\r\n            <groupId>com.googlecode.json-simple</groupId>\r\n            <artifactId>json-simple</artifactId>\r\n            <version>1.1.1</version>\r\n        </dependency>\r\n        \r\n        <dependency>\r\n\t\t<groupId>org.testng</groupId>\r\n\t\t<artifactId>testng</artifactId>\r\n\t\t<version>6.8.8</version>\r\n\t</dependency>\r\n\t\t\r\n\t<dependency>\r\n\t\t<groupId>com.jayway.restassured</groupId>\r\n\t\t<artifactId>rest-assured</artifactId>\r\n\t\t<version>2.4.0</version>\r\n\t</dependency>\r\n\r\n    </dependencies>\r\n\r\n\r\n```\r\n\r\nIf I change nothing in my application except change the boot version back to 1.1.9.RELEASE everything works as before. \r\n\r\nThanks for your help. \r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/comments/70541401","html_url":"https://github.com/spring-projects/spring-boot/issues/2200#issuecomment-70541401","issue_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2200","id":70541401,"user":{"login":"blimey74","id":2065606,"avatar_url":"https://avatars.githubusercontent.com/u/2065606?v=3","gravatar_id":"","url":"https://api.github.com/users/blimey74","html_url":"https://github.com/blimey74","followers_url":"https://api.github.com/users/blimey74/followers","following_url":"https://api.github.com/users/blimey74/following{/other_user}","gists_url":"https://api.github.com/users/blimey74/gists{/gist_id}","starred_url":"https://api.github.com/users/blimey74/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blimey74/subscriptions","organizations_url":"https://api.github.com/users/blimey74/orgs","repos_url":"https://api.github.com/users/blimey74/repos","events_url":"https://api.github.com/users/blimey74/events{/privacy}","received_events_url":"https://api.github.com/users/blimey74/received_events","type":"User","site_admin":false},"created_at":"2015-01-19T18:46:50Z","updated_at":"2015-01-19T18:46:50Z","body":"Hi Siamak, my question was aimed more at the Spring guys.  I've tried the NASA URL and it works fine with Spring 4.1.3.RELEASE.  I'm curious about your code, do you add any Http Headers to your request code? This is how my sample code looks:\r\n\r\n```java\r\n       REQUEST_FACTORY.setReadTimeout(10000);\r\n        REQUEST_FACTORY.setConnectTimeout(10000);\r\n\r\n        RestTemplate restTemplate = new RestTemplate(REQUEST_FACTORY);\r\n\r\n        HttpHeaders requestHeaders = new HttpHeaders();\r\n        requestHeaders.set(FIELDS_REQUEST_HEADER, \"default,activationTimes\");\r\n        HttpEntity<?> requestEntity = new HttpEntity(requestHeaders);\r\n\r\n        ResponseEntity response = restTemplate.exchange(\"http://data.nasa.gov/api/\",\r\n                HttpMethod.GET, requestEntity, String.class, \"\");\r\n\r\n\r\n        return (String) response.getBody();\r\n  ```"}}