使用@multipart 改造@Part Multipartbody.Part 抛出异常

Retrofit @Part Multipartbody.Part with @multipart throws exception

我正在实施这个问题Retrofit @body with @multipart having Issue。一切都很好。添加 @Part MultipartBody.Part 文件时出现问题。它抛出 Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $。如果有任何帮助,我将不胜感激。

NOTE: I am using custom converterFactory and Interceptor (by implementing Gson). Could that be problem?

@Part MultipartBody.Part file. It throws Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $.

这是 GSON 错误,这意味着您提供的模型与您从服务器收到的响应不匹配(在您的情况下,您收到的是平面字符串而不是 JSON)

为了解决您的问题,请 post 服务器的完整响应,以便您的模型 class