我用postman调用了这个函数,可以很好地工作,但是使用restemplate会产生400个错误。myurl未编码,其纯字符串=https://blabla.com/rest/create
getreqbody()返回一个有效的jsonnode
这里怎么了?任何建议都将不胜感激!
restTemplate1 = new RestTemplate();
ResponseEntity<JsonNode> response1 =null;
Object resObj1 =null;
try {
RequestEntity<JsonNode> request = RequestEntity
.post(URI.create(myURl))
.header("Authorization", "Basic " + basicAuth)
.contentType(MediaType.APPLICATION_JSON)
.body(getReqBody());
System.out.println(" My actual Request to -->" + request.toString());
response1 = restTemplate1.exchange(request, JsonNode.class);
}catch(Exception e) {
System.out.println("Caught it in Exception "+ e);
logger.error(" Error from Creation ==>" +e);
}
暂无答案!
目前还没有任何答案,快来回答吧!