Spring Boot RestTemplate获取请求发现401未授权异常

时间:2019-07-12 10:14:43

标签: java spring-boot resttemplate

以下代码段收到 401未经授权异常:

String uri = "https://api/example.json?status=all";
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity entity = new HttpEntity(headers);
ResponseEntity <String> results = restTemplate.exchange(uri, HttpMethod.GET, entity, String.class;

0 个答案:

没有答案