Code example for HttpPost

Methods: addHeader, getParams, setEntity

0
   * @throws ClientProtocolException 
   * @throws IOException 
   */ 
  public static ReadableResponse signedPostRequest(String request, List<NameValuePair> bodyParams, CommonsHttpOAuthConsumer consumer, String contentType) throws OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException, ClientProtocolException, IOException{
    HttpClient client = new DefaultHttpClient();
    HttpPost post = new HttpPost(request);
    post.setEntity(new UrlEncodedFormEntity(bodyParams, HTTP.UTF_8));
    post.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
    consumer.sign(post);
    post.addHeader("Content-Type", contentType);
    HttpResponse response = client.execute(post);
    return new HttpResponseWrapper(response);
  } 
 
  /** 
   * Sends a signed POST request using the Signpost library 
   * @param request the request's URL 
   * @param entity the message's contents 
   * @param consumer the Signpost consumer object 
   * @param contentType the message's content type 
   * @return the response