Alican Temel Alican Temel - 4 months ago 236x
Android Question

Android Retrofit post request multipart encoding error

I am facing this problem try to make post request with retrofit.

@Body parameters cannot be used with form or multipart encoding.

My body classes looks like below,

public class AddUser implements Serializable {
public String memberNo;
public List<AddUserLimit> limits;

public class AddUserLimit implements Serializable {
public String type;
public Value value;

public class Value implements Serializable {
public String unit;
public String unit_value;

And my interface method looks like below,

Call<ResponseBody> addMember(@QueryMap HashMap<String, Object> paramaters, @Body AddUser addUser);

I am waiting your helps.


You cannot use the @Body annotation with an @FormUrlEncoded annotation. You must use an @Part annotation, this annotation will compose the request body for you.