sogeti / DroidNetworking

A networking library for Android.
21 stars 12 forks source link

POST Request type array #9

Open levieggert opened 10 years ago

levieggert commented 10 years ago

Hey is it possible to POST a parameter of type array? I'm not getting any response when I try to post a JSONArray with JSONObjects. I've also tried an ArrayList of HashMaps.

Example of params:

//params HashMap params = new HashMap(); params.put("fromDate", "2014-03-20"); params.put("toDate", "2014-03-25"); params.put("rooms", jsonArray);//also tried jsonArray.toString();

Thank you!

netdev commented 10 years ago

Hi

DroidNetwork does not handle JSON objects directly so you have to use jsonArray.toString(). Since you are then posting a string I don't understand why it doesn't work. Have you tried to post data with a REST client to verify that the web service accepts the JSON data?

BR Martin

levieggert commented 10 years ago

Hey Martin,

Thank you for taking the time to respond. I just checked and the REST client does not take JSON. It has to be URL Encoded. Does your Framework support this type of functionality? If not, I'm assuming Java/Android will provide the functionality. I'll have to do some digging as I'm an iOS developer and Java/Android is new to me. BTW, I really like your networking framework. Simple to use. Keep up the good work.

Thanks,

Levi

On Mar 6, 2014, at 11:02 AM, Martin Dahl notifications@github.com wrote:

Hi

DroidNetwork does not handle JSON objects directly so you have to use jsonArray.toString(). Since you are then posting a string I don't understand why it doesn't work. Have you tried to post data with a REST client to verify that the web service accepts the JSON data?

BR Martin

— Reply to this email directly or view it on GitHub.

netdev commented 10 years ago

Strange. The parameters are url encoded by DroidNetworking. If you prefer you can use the new method public void setBody(final byte[] body); to set a raw body instead. You then have full control of how you encode the json-data.