New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用含有@Body的@Get方法报错:Non-body HTTP method cannot contain @Body. #55
Comments
按照HTTP规范,get请求方式就是不支持请求体的😂 |
感谢您的回复: ] |
今天查了下,get确实可以传body,但是一般不推荐这么使用。我研究一下retrofit怎么传😂,之前没碰到过 |
|
感谢, 这个方式报错信息意思一样. 还是通不过 |
作者给出了具体原因,可以参考这个issue:square/okhttp#3154 but,如果实在需要这么干,我想到一种方式,可以使用 |
谢谢. 不过小写的get对我不起作用, kafka端不允许get请求,只允许GET请求. 不过我看了很多http客户端(apache httpclient, spring webclient等), 基本上都不支持get带body. 看来只能用最原始的方法了. 再次谢谢您的帮助! |
Hi, 我的问题如下:
我使用retrofit调用Kafka Rest接口, 接口要求使用Get方法,并且须带有一个Json格式的body,我的定义如下
@Headers({"Content-Type:application/vnd.kafka.json.v2+json"}) @GET("consumers/{group_name}/instances/{instance_name}/offsets") Call<JsonNode> getOffsets(@Path("group_name") String groupName, @Path("instance_name") String instanceName, @Body RequestBody body);
执行时报错: Non-body HTTP method cannot contain @Body.
可否协助解决?
The text was updated successfully, but these errors were encountered: