【发布时间】:2021-08-09 03:16:11
【问题描述】:
我正在尝试创建表单数据发布请求,尝试使用@Part, @Field, @FieldMap, and @Body,但也没有成功。我通过邮递员测试了请求,它工作正常,但每次在 Android Studio 中,都会出现相同的错误
java.io.EOFException: End of input at line 1 column 1 path $
尝试
1. @Multipart
@POST("/forum/")
Observable<Comment> postComment(
@Part("content") RequestBody comment,
@Part("type") RequestBody type,
@Part("parent_id") RequestBody parent_id
);
2. @POST("/forum/")
@FormUrlEncoded
Observable<Comment> postComment(
@Field("content") String comment,
@Field("type") String type,
@Field("parent_id") String parent_id
);
3. @POST("/forum/")
@FormUrlEncoded
Observable<Comment> postComment(
@FieldMap Map<String, String> params
);
4. @POST("/forum/")
//@Multipart
Observable<Comment> postComment(
@Body RequestBody body
);
虽然在 Postman 上工作正常:
【问题讨论】:
标签: java android retrofit form-data