来自发布请求的响应为空

时间:2021-02-15 16:15:38

标签: spring-boot java-7 restapi

我从邮递员那里收到了以下 WS 我请求,并带有以下参数: enter image description here

我从邮递员控制台获得以下内容

enter image description here 我正在尝试使用以下代码段请求 WS:

logger.info("generating new token from "+URL);
expritation = new Date();
        
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
MultiValueMap<String, String> map= new LinkedMultiValueMap<>();
map.add("userUid", userUid);
map.add("appUid", appUid);
map.add("ttl", ttl);
restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(WsLogin, WsPassword));
ResponseEntity<String> response = restTemplate.postForEntity(URL, map , String.class);
return response.getBody();

我可以在 postman 中看到响应正文,但是 response.getBody() 在 java 代码中是空的。

谁能向我解释为什么会这样。

1 个答案:

答案 0 :(得分:0)

您的意思是您在 Postman 中看到了响应正文,但在您的编中没有看到?您是否尝试在从方法返回之前调试打印响应值?