0

I need to generate key as customerContactList[0].customerContactId from Pojo. I have tried with arrayList but I am able to generate in below format customerContactList=[{ customerContactId=2 } ] which seems invalid for API request.

  • this Post API accept form-data
  • If I pass in key value pair formParams.put("customerContactList[0].customerContactId", 2); then it is consider as valid. But I need to generate same format through Pojo.

1 Answers1

0

Your standard pojo should look like this.

{
  "customerContactList": [
    {
      "customerContactId": 2
    },
    {
      "customerContactId": 3
    }
  ]
}

May be this will help you.

class Pojo {
    List<CustomerContact> customerContactList;
}

class CustomerContact {
    int customerContactId;
}
Sagar Gangwal
  • 7,544
  • 3
  • 24
  • 38
  • I had tried in same way also, after this I have created object of Pojo class and in parameterize constructor I have pass that array object. After that I am converting that java object to Map for key value pair. But it does not generate key which I require to pass as per my question. – Rajput Yuvraj Aug 18 '20 at 19:19