gpt4 book ai didi

java - 如何使用 FeignClient 发送字符串

转载 作者:太空宇宙 更新时间:2023-11-04 11:01:42 24 4
gpt4 key购买 nike

服务器使用request.getInputStream()获取请求正文。

客户端代码:

@FeignClient(name="composer-agent")
public interface ComposerClient {
@RequestMapping(value = "/agent/import_bp", method = RequestMethod.POST)
String importBlueprints(String payload);
}

但我遇到了一个异常(exception):

Caused by: feign.FeignException: status 500 reading ComposerClient#importBlueprints(String); content:
{"timestamp":"2017-10-19T06:15:47-0400","status":500,"error":"Internal Server Error","exception":"java.lang.IllegalArgumentException","message":"MIME type may not contain reserved characters"}
at feign.FeignException.errorStatus(FeignException.java:62)
at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:91)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:138)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76)
at feign.hystrix.HystrixInvocationHandler$1.run(HystrixInvocationHandler.java:108)
at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:301)
at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:297)
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46)
... 144 common frames omitted

我还尝试设置 consumes = MediaType.APPLICATION_JSON_VALUE 或其他值,或添加 @RequestBody,但我得到了相同的异常。

那么我该如何解决这个问题呢?谢谢。

最佳答案

这是一个known bug在 Feign 9.3.0 中,底层 HTTP 客户端是 Apache HTTP 客户端。解决方案是升级feign-httpclient依赖。例如:

compile "io.github.openfeign:feign-httpclient:9.5.0"

关于java - 如何使用 FeignClient 发送字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46828241/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com