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

sending json in payload not supported? #14

Closed
orrgal1 opened this issue Jan 20, 2013 · 3 comments
Closed

sending json in payload not supported? #14

orrgal1 opened this issue Jan 20, 2013 · 3 comments

Comments

@orrgal1
Copy link

orrgal1 commented Jan 20, 2013

hi,
trying to do the equivalent of
curl http://URL -d '{JSON}'

cant find a way to do it. seems like all the requests here work on a key=value basis and there is no way to just send the Json in the payload.

currently doing it with Apaches HttpClient as below but would love to simplify my code using your package:

        HttpPost request = new HttpPost(url);
        String s = cmd.toString();
        StringEntity params = new StringEntity(s);
        request.addHeader(CONTENT_TYPE, APPLICATION_JSON);
        request.setEntity(params);
        httpClient.execute(request);
@marczych
Copy link

You can use the send method to send an arbitrary String in the request body. e.g.

String json = "{JSON}";
HttpRequest request = new HttpRequest("http://URL", "POST");
request.send(json);

String responseBody = request.body();
int code = request.code();

@orrgal1
Copy link
Author

orrgal1 commented Jan 20, 2013

aha... must've missed that option. thanks dude.

Sent from my Hot Pink Asus Zenbook

On Sun, Jan 20, 2013 at 9:02 PM, Marc Zych notifications@github.com wrote:

You can use the send method to send an arbitrary String in the request
body. e.g.

String json = "{JSON}";HttpRequest request = new HttpRequest("http://URL", "POST");request.send(json);
String responseBody = request.body();int code = request.code();


Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-12475375.

@kevinsawicki
Copy link
Owner

@marczych thanks for pointing that out.

@orrgal1 I'm going to close this issue but please feel free to reopen if you have any issues with the API recommended.

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

3 participants