2

I am triggering a GET request and getting the JSON data successfully via Spring RestTemplate. I also want to get the Response Header information but I am not sure how to get it.

private String getAPIKeySpring() {
        RestTemplate restTemplate = new RestTemplate();
        String url = baseURL+"/users/apikey";
        Map<String, String> vars = new HashMap<String, String>();
        vars.put("X-Auth-User", apiUser);
        JsonVO jsonVO =  restTemplate.getForObject(url, JsonVO.class, vars);
        System.out.println(jsonVO);
        return null;
    }
Zeeshan
  • 11,851
  • 21
  • 73
  • 98

1 Answers1

4
ResponseEntity<JsonVO> responseEntity =  restTemplate.getForEntity(url, JsonVO.class, vars);
JsonVO jsonVO = responseEntity.getBody();
HttpHeaders headers = responseEntity.getHeaders(); //<-- your headers
codependent
  • 23,193
  • 31
  • 166
  • 308