Search code examples
androidretrofit2multipartform-datamultipart

Retrofit @Part Multipartbody.Part with @multipart throws exception


I am implementing this question Retrofit @body with @multipart having Issue. Everything works great. Problem arises while adding @Part MultipartBody.Part file. It throws Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $. I would appreciate any help.

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


Solution

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

    This is GSON error and it means that model that you provided does not match to response you received from your server (In your case you received plane string instead of JSON)

    In order to solve your issue please post full response from server so as your model class