Skip to content

Instantly share code, notes, and snippets.

@jcarlosgarcia
Created July 6, 2012 12:44
Show Gist options
  • Save jcarlosgarcia/3059977 to your computer and use it in GitHub Desktop.
Save jcarlosgarcia/3059977 to your computer and use it in GitHub Desktop.
Sending a POST request to a REST service using Apache HttpClient
HttpClient client = new HttpClient();
String url = "url destination";
PostMethod method = new PostMethod(url);
method.setParameter("param1", "value1");
method.addParameter("param2", "value2");
client.executeMethod(method);
InputStream response = method.getResponseBodyAsStream();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment