I wish to append a List<Beans> in a HTTP Post request.
While making use of Apache HTTPClient, I am unable to do the same.
This is what I wish to do:
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("dailySalesList",beanList));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
However, the BasicNameValuePair seems to take only 2 Strings as argument. I wish to utilize it so that I can use a String – for identification and Object – to pass a List.
Basically a functionality similar to using a Map.
Any pointers on how it can be done using Apache HTTPClient ?
Thanks Kiyura for pointing me in the right direction, to make use of JSON.
I made use of the GSON java library for conversion from List to JSON representation.
Its a pretty library in case you want to use JSON without manually converting Generic Types.
The gson doc is also a good reference.