code: private static void writePostRequest(URLConnection connection, String postRequestBody, String contentType) throws IOException {
          connection.setDoOutput(true); // whether we want to write to the connection
  
          if (contentType != null) {
              connection.setRequestProperty("Content-Type", contentType);
          }
          // Note: Content-Length is set implicitly by URLConnection
          try (DataOutputStream out = new DataOutputStream(connection.getOutputStream())) {
              out.writeBytes(postRequestBody);
          }
      }
docs: /*
  Write POST request header and body