Newly modified form and multi-page code in one request

public interface PostMessage {
@Multipart
@POST("https://www.example.com/message")
void sendMessage(@QueryMap Map<String, String> queryMap,
        @Part("image") TypedFile imagefile, Callback<Response> response);
}

I tried queryMap encryption using @Feild and @Body. But this gives an IllegalArgumentException with the message "Only one annotation is allowed for encoding . "

My question is:
Can data encryption with multipart be used in one request?

+4
source share
1 answer

Just for sharing: Another way to do this is to

public interface PostMessage {
@Multipart
@POST("https://www.example.com/message")
void sendMessage(@PartMap Map<String, String> partMap,
        @Part("image") TypedFile imagefile, Callback<Response> response);
}
Run codeHide result

UPDATE: with Retrofit2

public interface PostMessage {
@Multipart
@POST("https://www.example.com/message")
Call<Response> sendMessage(@PartMap Map<String, String> partMap,
        @Part("image") TypedFile imagefile);
}
+3
source

All Articles