@Test public void testPostRequest() throws Exception { RestCommunicationHandler.postRequest("https: }
public static String postRequest(String urlStr, Boolean doAuth, String encodedAuth, String jsonCred) throws IOException { ProxyUtil.disableCertificates(); ProxyUtil.setProxy(); StringBuilder stb = new StringBuilder(); URL url = new URL(urlStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); if(doAuth) { if (jsonCred==null) { conn.setRequestProperty("Authorization", "Basic " + encodedAuth); } else { OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(jsonCred); wr.flush(); } } BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); String output; while ((output = br.readLine()) != null) { stb.append(output); } conn.disconnect(); return stb.toString(); }
RestCommunicationHandler { public static String postRequest(String urlStr, Boolean doAuth, String encodedAuth, String jsonCred) throws IOException { ProxyUtil.disableCertificates(); ProxyUtil.setProxy(); StringBuilder stb = new StringBuilder(); URL url = new URL(urlStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); if(doAuth) { if (jsonCred==null) { conn.setRequestProperty("Authorization", "Basic " + encodedAuth); } else { OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(jsonCred); wr.flush(); } } BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); String output; while ((output = br.readLine()) != null) { stb.append(output); } conn.disconnect(); return stb.toString(); } }
RestCommunicationHandler { public static String postRequest(String urlStr, Boolean doAuth, String encodedAuth, String jsonCred) throws IOException { ProxyUtil.disableCertificates(); ProxyUtil.setProxy(); StringBuilder stb = new StringBuilder(); URL url = new URL(urlStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); if(doAuth) { if (jsonCred==null) { conn.setRequestProperty("Authorization", "Basic " + encodedAuth); } else { OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(jsonCred); wr.flush(); } } BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); String output; while ((output = br.readLine()) != null) { stb.append(output); } conn.disconnect(); return stb.toString(); } private  RestCommunicationHandler(); }
RestCommunicationHandler { public static String postRequest(String urlStr, Boolean doAuth, String encodedAuth, String jsonCred) throws IOException { ProxyUtil.disableCertificates(); ProxyUtil.setProxy(); StringBuilder stb = new StringBuilder(); URL url = new URL(urlStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); if(doAuth) { if (jsonCred==null) { conn.setRequestProperty("Authorization", "Basic " + encodedAuth); } else { OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(jsonCred); wr.flush(); } } BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); String output; while ((output = br.readLine()) != null) { stb.append(output); } conn.disconnect(); return stb.toString(); } private  RestCommunicationHandler(); static String getResponse(String urlStr, Boolean doAuth, String authType, String encodedAuth); static String postRequest(String urlStr, Boolean doAuth, String encodedAuth, String jsonCred); }
RestCommunicationHandler { public static String postRequest(String urlStr, Boolean doAuth, String encodedAuth, String jsonCred) throws IOException { ProxyUtil.disableCertificates(); ProxyUtil.setProxy(); StringBuilder stb = new StringBuilder(); URL url = new URL(urlStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); if(doAuth) { if (jsonCred==null) { conn.setRequestProperty("Authorization", "Basic " + encodedAuth); } else { OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(jsonCred); wr.flush(); } } BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); String output; while ((output = br.readLine()) != null) { stb.append(output); } conn.disconnect(); return stb.toString(); } private  RestCommunicationHandler(); static String getResponse(String urlStr, Boolean doAuth, String authType, String encodedAuth); static String postRequest(String urlStr, Boolean doAuth, String encodedAuth, String jsonCred);  }