Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST Request type array #9

Open
levieggert opened this issue Mar 5, 2014 · 3 comments
Open

POST Request type array #9

levieggert opened this issue Mar 5, 2014 · 3 comments

Comments

@levieggert
Copy link

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
Copy link
Contributor

netdev commented Mar 6, 2014

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
Copy link
Author

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 [email protected] 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
Copy link
Contributor

netdev commented Mar 13, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants