Reputation: 729
This might seem similar to earlier questions but none actually answers my question. I need to Post multiple fields and multiple images in one request using retrofit2 and i'm getting this error
java.lang.IllegalArgumentException: Only one encoding annotation is allowed.for method xxx
i'm using
@Multipart
@FormUrlEncoded
since @Field requires @FormUrlEncoded and @Part requires @Multipart. the more logical thing to do is to remove the @FormUrlEncoded annotation, but how do i go from there. Now the question is how do i go about the task to achieve sending my post in a single request.
here's the interface
@Multipart
@FormUrlEncoded
@POST("upload")
Call<ResponseBody> uploadPost(@FieldMap Map<String, String> map,
@Part MultipartBody.Part image1,
@Part MultipartBody.Part image2,
@Part MultipartBody.Part image3);
Upvotes: 2
Views: 3548
Reputation: 1187
@Multipart
@POST("upload")
Call<ResponseBody> uploadPost(
@PartMap() Map<String, RequestBody> descriptions,
@Part List<MultipartBody.Part> images);
use this interface.
Upvotes: 3