开发者社区 问答 正文

Resttemplate 请求失败如何获取返回的json体?报错

写后台用Resttemplate请求失败的话只会在后台报错400或者401或者其他的,用postman失败的话,是可以看到返回的错误json体的,有什么简单的办法可以在后台使用的时候也获取返回的error json

展开
收起
爱吃鱼的程序员 2020-06-06 16:46:08 856 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <pre><code>try {
    // resttemplate call api
    

    } catch (HttpClientErrorException e) { e.getResponseBodyAsString(); }

    2020-06-06 16:46:21
    赞同 展开评论