public UserRealInfoVO getInquiryData(OnlyIdStr id) {
id.validate();
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json;charset=UTF-8");
headers.add("Authorization", "Bearer " + warrantConfig.getToken());
// 请求
HttpEntity<String> request = new HttpEntity<>(id.getId(), headers);
JSONObject jsonObject = restTemplate.postForObject(warrantConfig.getUrl(), request, JSONObject.class);
if (jsonObject == null) {
return null;
}
try {
if (jsonObject.get("code").equals(200) && jsonObject.get("data") != null) {
return JSONObject.parseObject(JSONObject.toJSONString(jsonObject.get("data")), UserRealInfoVO.class);
}
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
java携带请求头远程调用
最新推荐文章于 2023-11-30 16:07:11 发布