Using the spring cloud feign call my service, when the service return 401 exception, the respose.body()
is null.
When I throw the exception that is throw new BadRequestException(400, “this http code is 400”);
I can get the error message that this http code is 400
by response.body()
.
But when I throw the exception throw new BadRequestException(401, “this http code is 401”);
, the response.body()
is null.
This response is feign.Response
.
Why I can`t get this error message when http code is 401?
Hope your help! Thank you very much!
Switch to feign-okhttp will fix your problem.
Add in Pom:
<dependency>
<groupId>com.netflix.feign</groupId>
<artifactId>feign-okhttp</artifactId>
<version>8.18.0</version>
</dependency>
And add in your config:
feign.okhttp.enabled: true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With