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

Is there a way to POST using JSON? #24

Closed
ghost opened this issue Mar 12, 2013 · 2 comments
Closed

Is there a way to POST using JSON? #24

ghost opened this issue Mar 12, 2013 · 2 comments

Comments

@ghost
Copy link

ghost commented Mar 12, 2013

I know I can make a post with the DefaultHttpClient for JSON (http://stackoverflow.com/questions/6533234/how-to-make-httppost-call-with-json-encoded-body), but I'd like to use http-request and can't figure out how to do it. So far what I did was cast the JSON to a Map<String, String>, but that has unfortunate side effects, such as doing away with native arrays and numbers. I'm trying to figure out how to use http-request with request.form or something similar.

@kevinsawicki
Copy link
Owner

You need a JSON library such as gson or Jackson to convert what you want to send to JSON.

These libraries will allow you to convert your objects to JSON and then you can forward that JSON as a String or InputStream using this library.

@ghost
Copy link
Author

ghost commented Mar 12, 2013

Awesome, I'm actually using gson already, didn't realize I could just append the created json to it. Thanks!

@ghost ghost closed this as completed Mar 12, 2013
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant