restemplate返回400个错误请求

pftdvrlh  于 2021-07-23  发布在  Java
关注(0)|答案(0)|浏览(300)

我用postman调用了这个函数,可以很好地工作,但是使用restemplate会产生400个错误。myurl未编码,其纯字符串=https://blabla.com/rest/create
getreqbody()返回一个有效的jsonnode
这里怎么了?任何建议都将不胜感激!

  1. restTemplate1 = new RestTemplate();
  2. ResponseEntity<JsonNode> response1 =null;
  3. Object resObj1 =null;
  4. try {
  5. RequestEntity<JsonNode> request = RequestEntity
  6. .post(URI.create(myURl))
  7. .header("Authorization", "Basic " + basicAuth)
  8. .contentType(MediaType.APPLICATION_JSON)
  9. .body(getReqBody());
  10. System.out.println(" My actual Request to -->" + request.toString());
  11. response1 = restTemplate1.exchange(request, JsonNode.class);
  12. }catch(Exception e) {
  13. System.out.println("Caught it in Exception "+ e);
  14. logger.error(" Error from Creation ==>" +e);
  15. }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题