Reputation: 4140
I'm Using the below code in Android, retrofit, to upload an image:
@Multipart
@POST("uploadimage")
Call<ImageUploadResponse> uploadImage(@PartMap Map<String, RequestBody> map);
But what if I need to send extra data, such as Image Description along with the request?
I Was not able to use @Field, that is i tried like this:
@Multipart
@FormUrlEncoded
@POST("uploadimage")
Call<ImageUploadResponse> uploadImage(@PartMapMap<String,RequestBody> map,
@Field("description")String desc);
I got an error stating that only one annotation is allowed. That is either @Multipart or @FormUrlEncoded.
Upvotes: 0
Views: 84
Reputation: 6277
You can use @Part instead of @Field
@Multipart
@POST("uploadimage")
Call<ImageUploadResponse> uploadImage(@PartMap Map<String, RequestBody> map, @Part("description") String description);
Upvotes: 1