在api需要一些奇怪的传参方式时,比如post里必须要用问号接参数的形式时,可能会产生411错误。
HTTP Error 411. The request must be chunked or have a content length.
解决方法:传参时,添加一个JSONObect的形参
@FeignClient(name = "f", url = "*")
public interface testFeign{
@PostMapping("/test")
String test(@RequestParam(value = "input") String input, @RequestBody JSONObject jsonObject);
}
实参为new JSONObject("{}")
feignClient.test("api需要的参数", new JSONObject("{}"));
参考来源:
Getting 411 Length Required Error · Issue #1251 · OpenFeign/feign · GitHub

本文介绍了解决FeignClient中出现的411 Length Required错误的方法。当API需要特殊的参数传递方式时,例如POST请求必须使用问号连接参数的形式,可能会遇到此问题。解决方案是在发送请求时附加一个空的JSONObject。

5838

被折叠的 条评论
为什么被折叠?



