我正在尝试在SpringBoot 2应用程序中执行GET调用。虽然我得到了200的响应代码,但我仍然能够在RestClient中看到响应
我尝试设置诸如ContentType和AcceptType之类的标题。但这也不起作用。
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(new MediaType[] { MediaType.APPLICATION_JSON }));
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> entity = new HttpEntity<String>(headers);
ResponseEntity<String> response = template.exchange(endPointUrl, HttpMethod.GET, entity, String.class);
RestTemplate template = new RestTemplate();
ResponseEntity<String> result = template.getForEntity(endPointUrl, String.class);