gpt4 book ai didi

android - @Part 参数只能与多部分编码一起使用。 (参数#8)

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:57:31 25 4
gpt4 key购买 nike

在我在这里发布这个问题之前,我尝试在接口(interface)方法上方添加 @Multipart 并且在 stackoverflow 中搜索仍然找不到与我的问题相似的问题。

在这种情况下,我尝试使用 TypedFile 将图像发送到服务器。我的接口(interface)方法如下所示:

 @Headers({"Content-type: application/json"})
@POST("/user/change")
void postChange(@Query("name") String name, @Query("email") String email, @Query("password") String password, @Query("phone") String phone, @Query("user_id") String userId, @Query("address[]") String[] listAddress, @Query("head[]") String[] head, @Part("photo_profile") TypedFile photoProfile, @Body TypedInput jsonObject, Callback<ReceiveDTO> callback);

编辑

在该方法中我们可以看到@Part@Body。如果我在方法上方添加 @Multipart,我们将抛出错误 @Body parameters cannot be used with form or multi-part encoding。 (参数 #9)

我正在使用 Retrofit 1.9

最佳答案

对于有相同问题的任何人,请确保在您的@POST/@PUT 上方添加@Multipart 注释。我有同样的错误,我的问题只是我缺少那个 @Multipart 注释。

关于android - @Part 参数只能与多部分编码一起使用。 (参数#8),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39198720/

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