public
Created

Sending a POST request to a REST service using Apache HttpClient

  • Download Gist
gistfile1.java
Java
1 2 3 4 5 6 7 8 9 10
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();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.