Alican Temel
Alican Temel

Reputation: 1318

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,

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

I am waiting your helps.

Upvotes: 0

Views: 885

Answers (1)

Bryan
Bryan

Reputation: 15155

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.

Upvotes: 2

Related Questions