title: How to POST xml data while calling API through JAVA?
body: <p>I am creating an application where I want to POST xml data directly (without key value pair) to API. The API needs certification authentication which is done here in code. Now I want to POST the data to same URL.</p>
  
  <p>Here is what I want to do : </p>
  
  <p><a href="https://i.stack.imgur.com/XiJqP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XiJqP.png" alt="enter image description here"></a>
  My current code is : </p>
  
  <pre><code>@Override
      public String demoAPI(String xmlData) {
          StringBuilder sb = new StringBuilder();
          String output="";
      try {
          KeyStore clientStore = KeyStore.getInstance("PKCS12");
          clientStore.load(new FileInputStream(new File("path-to-pfx-file")),
                  "password".toCharArray());
          KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
          kmf.init(clientStore, "password".toCharArray());
          KeyManager[] kms = kmf.getKeyManagers();
          KeyStore trustStore = KeyStore.getInstance("JKS");
          trustStore.load(new FileInputStream("path-to-jks-file"), "password".toCharArray());
          TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
          tmf.init(trustStore);
          TrustManager[] tms = tmf.getTrustManagers();
          final SSLContext sslContext = SSLContext.getInstance("TLS");
          sslContext.init(kms, tms, new SecureRandom());
          SSLContext.setDefault(sslContext);
          HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE;
          HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
          HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
          URL url = new URL("URL");
          HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
          con.setRequestMethod("GET");
          con.setConnectTimeout(100000);
          con.setSSLSocketFactory(sslContext.getSocketFactory());
          con.connect();
          BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
          String line;
          while ((line = br.readLine()) != null) {
              sb.append(line + "\n");
          }
          br.close();
          System.out.println(sb.toString());
          output = sb.toString();
      } catch (Exception e) {
          e.printStackTrace();
          output = e.getMessage();
      }
      return output;
  }
  </code></pre>
  
  <p>Whereas , for same url , I want to POST xmlData from method. 
  How can I do that ? What should I change in the code after 
  <code>con.setRequestMethod("POST");</code> ?  </p>