feign.FeignException$NotAcceptable: [406 Not Acceptable]

in http406 •  3 years ago  (edited)

xing-kong-qiangzhi-1600x900_47.jpg

测试环境调用第三方,发现一直feign报错,前几天还是好的,这块代码也不会去改动

feign.FeignException$NotAcceptable: [406 Not Acceptable] during [POST] to [http://test.skypay.ph/services/Lightning2] [SkypayRemoteService#invoke(String,String)]: []
    at feign.FeignException.clientErrorStatus(FeignException.java:205)



查了好久,最后本地debug,发现是header的accept导致的

    @Headers({"Content-Type: application/json","Accept: application/json"})
    @RequestLine("POST /{callName}")
    String invoke(String encryptedStr, @Param("callName")String callName);


根据wiki的定义,Accept指定能够接受的回应内容类型(Content-Types),由于三方把原本response的Content-Types改成text/plain,
导致feign这边无法接收而406错误了

解决方法去掉Accept就好了,默认是

Accept: */*
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!