1. HttpHeaders headers = new HttpHeaders();
    2. headers.set("authorization", AuthorizationConstant.BEARER_AUTHORIZATION);
    3. HttpEntity<String> requestEntity = new HttpEntity<>(headers);
    4. //GET
    5. BuildinglotResponseEntity body = restTemplate.exchange(
    6. realtimeApi+"?deviceId="+deviceId,
    7. HttpMethod.GET,
    8. requestEntity, BuildinglotResponseEntity.class
    9. ).getBody();
    10. //post参数设置
    11. MultiValueMap<String, Object> stringObjectHashMap = new LinkedMultiValueMap<>();
    12. stringObjectHashMap.put(key, value);
    13. HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(stringObjectHashMap,headers);
    14. BuildinglotResponseEntity body = restTemplate.exchange(
    15. realtimeApi,
    16. HttpMethod.POST,
    17. requestEntity, BuildinglotResponseEntity.class
    18. ).getBody();