Alican Temel Alican Temel - 2 years ago 868
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download