Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String post(String address, String request) {
- String response = "";
- try {
- URL obj = new URL(address);
- HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
- con.setRequestMethod("POST");
- con.setRequestProperty("Authorization", authorization);
- con.setRequestProperty("Content-Type", "application/json");
- con.setDoOutput(true);
- DataOutputStream wr = new DataOutputStream(con.getOutputStream());
- wr.writeBytes(request);
- wr.flush();
- wr.close();
- BufferedReader in = new BufferedReader(
- new InputStreamReader(con.getInputStream()));
- String line;
- while ((line = in.readLine()) != null) {
- response += line;
- }
- in.close();
- } catch (IOException e) {
- logger.error("HttpsRequestHandler error: " + e.getMessage());
- return null;
- }
- return response;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement