HttpHeaders headers = new HttpHeaders();
headers.set("authorization", AuthorizationConstant.BEARER_AUTHORIZATION);
HttpEntity<String> requestEntity = new HttpEntity<>(headers);
//GET
BuildinglotResponseEntity body = restTemplate.exchange(
realtimeApi+"?deviceId="+deviceId,
HttpMethod.GET,
requestEntity, BuildinglotResponseEntity.class
).getBody();
//post参数设置
MultiValueMap<String, Object> stringObjectHashMap = new LinkedMultiValueMap<>();
stringObjectHashMap.put(key, value);
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(stringObjectHashMap,headers);
BuildinglotResponseEntity body = restTemplate.exchange(
realtimeApi,
HttpMethod.POST,
requestEntity, BuildinglotResponseEntity.class
).getBody();