The list of methods to do HTTP Post are organized into topic(s).
void
doHttpPost(URL url, String requestBody) Executes a HTTP-POST Request
HttpURLConnection connection = null;
OutputStreamWriter writer = null;
try {
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("Content-Length", String.valueOf(requestBody.length()));
writer = new OutputStreamWriter(connection.getOutputStream());
...
byte[]
doPost(String targetURL, String urlParameters, String contentType) executes a post to the targetURL.
URL url;
HttpURLConnection connection = null;
try {
url = new URL(targetURL);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", contentType);
connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
...
String
doPost(String theURL, Map nameValuePairs) do Post
URL url = new URL(validateURL(theURL));
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
postRequest(conn, nameValuePairs);
return readResponse(conn);
String
executePost(String url, JSONObject data) execute Post
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("User-Agent", "Mozilla/5.0");
con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
con.setRequestProperty("Content-Type", "application/json");
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
...
String
executePostWithCredentials(String targetURL, String urlParameters, String userName, String password) execute Post With Credentials
HttpURLConnection connection = null;
try {
String userPassword = userName + ":" + password;
String encoded = Base64.getEncoder().encodeToString(userPassword.getBytes("UTF-8"));
URL url = new URL(targetURL);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
...
HttpURLConnection
getHttpPOSTConnection(String urlStr, String charSet, Map props, Map params) get Http POST Connection
URL url = new URL(urlStr);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
for (Iterator iterator = props.keySet().iterator(); iterator.hasNext();) {
String k = (String) iterator.next();
connection.addRequestProperty(k, props.get(k));
connection.setRequestMethod("POST");
connection.setDoOutput(true);
...
InputStream
httpGet(final String httpurl, final Map... requestProperties) Simple http get imlementation.
HttpURLConnection connection = (HttpURLConnection) new URL(httpurl).openConnection();
for (Map<String, String> props : requestProperties) {
addRequestProperties(props, connection);
return connection.getInputStream();
InputStream
httpPost(final String httpurl, final String data, final Map... requestProperties) Simple http post implementation.
byte[] bytes = data.getBytes("utf-8");
java.net.URL url = new java.net.URL(httpurl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("charset", "utf-8");
connection.setRequestProperty("Content-Length", Integer.toString(bytes.length));
...