Aditya Chandra Aditya Chandra - 9 months ago 57
Android Question

Passing lots parameters including arrays in retrofit

I need to send this request to my API

?name=yourname&address=youraddress&phone=1245689& .. 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 Source

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