RestTemplate - exchange

1. Get

HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", token);
headers.set("Prefer", "odata.maxpagesize=" + microsoftConfig.getPageSize());
// 2.1 发起请求
ResponseEntity<HashMap> response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<String>(headers), HashMap.class);

2. Post

RequestEntity<String> requestEntity = RequestEntity.post(URI.create(postUrl))
                    .accept(MediaType.APPLICATION_JSON)
                    .header("Content-Type", "application/json")
                    .header("Authorization", getToken())
                    .body(s);
restTemplate.exchange(requestEntity, Object.class);