2
使用spring cloud feign調用我的服務,當服務返回401異常時,respose.body()
爲空。當http代碼爲401時,使用spring cloud feign,respose.body()爲null
當我拋出異常是throw new BadRequestException(400, 「this http code is 400」);
我可以得到this http code is 400
由response.body()
的錯誤信息。 但是,當我拋出異常throw new BadRequestException(401, 「this http code is 401」);
,response.body()
爲空。 此回覆爲feign.Response
。
爲什麼當http代碼是401時我不能得到這個錯誤信息?
希望你的幫助!非常感謝你!
謝謝您的回答!使用'ApacheHttpClient'也是可以的。你能告訴我爲什麼HttpUrlConnection關閉錯誤碼爲什麼錯誤代碼是401或407? –