Aditya Chandra Aditya Chandra - 1 month ago 10
Android Question

Passing lots parameters including arrays in retrofit

I need to send this request to my API

?name=yourname&address=youraddress&phone=1245689&email=me@mail.com&gender=M&birth_date=01011998&birth_place=Surabaya&job=myjob .. other 7 string parameters .. &skills[]=skill1&skills[]=skill2


I could do it like this How to post array in retrofit android

But, is there a simple way to do it in retrofit using @Body rather than @Field/@FieldMap?

Answer

I have resolved this by following this answer, but if you are to lazy and has made tons of code and don't want to rewrite them, just use List<Object> myObject = new ArrayList<Object>(); (using my own code as example) :

class UserFormRequest {

    private String name;
    private String address;
    ...
    private List<SkillObject> skills = new ArrayList<SkillObject>(); // this

}
Comments