简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM