Java Utililty Methods HTTP Post

List of utility methods to do HTTP Post

Description

The list of methods to do HTTP Post are organized into topic(s).

Method

StringhttpPost(String httpUrl)
http Post
BufferedReader input = null;
StringBuilder sb = null;
URL url = null;
HttpURLConnection con = null;
try {
    url = new URL(httpUrl);
    try {
        con = (HttpURLConnection) url.openConnection();
...
inthttpPost(String url, StringBuffer data)
http Post
return httpPost(url, data, null);
StringhttpPost(String urlToRead, String post)
Performs synchronous HTTP POST request with raw data, returns the response.
return httpPost(urlToRead, post, Proxy.NO_PROXY);
StringhttpPostText(String urlStr, String textString)
http Post Text
URL url = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "text/plain");
conn.setRequestProperty("Accept", "application/json");
conn.setDoOutput(true);
OutputStream out = conn.getOutputStream();
Writer writer = new OutputStreamWriter(out, "UTF-8");
...
Stringpost(String json, String url)
post
HttpURLConnection connection = (HttpURLConnection) (new URL(url)).openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setRequestProperty("Content-Type", "application/JSON");
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
out.writeBytes(json);
int code = connection.getResponseCode();
...
Stringpost(String json, String url)
post
HttpURLConnection connection = (HttpURLConnection) (new URL(url)).openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setRequestProperty("Content-Type", "application/JSON");
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
out.writeBytes(json);
int code = connection.getResponseCode();
...
Stringpost(String rawUrl, String body)
post
BufferedReader reader = null;
OutputStream out = null;
try {
    URL url = new URL(rawUrl);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod("POST");
    connection.setDoOutput(true);
    connection.setDoInput(true);
...
Listpost(String url, int timeout, Map header)
Method to make a POST request to the specified url
return request(url, timeout, "POST", header);
Stringpost(String url, JsonNode body)
post
return post(url, body.toString());
Stringpost(String url, Map params, String charset)
post
return post(url, params, null, charset);