title: Making a HTTPS Post request using XML in Java
body: <p>I'm trying to use the API from Web Of Knowledge(WoK) to obtain some data. The documentation explain that you have to do POST Requests through HTTPS, sending a XML which contains the queries. But I only get the error 400 form server. (Bad Request)</p>
  
  <p>Here is my code, I found it in Google and I make some fixes for my case.</p>
  
  <pre><code>public static void main(String[] args) throws Exception {
  
  
  
      // Get target URL
      String strURL = /*Here the Server URL*/;
  
      // Get file to be posted
      String strXMLFilename = "src/main/resources/xml/wosdata.xml";
      File input = new File(strXMLFilename);
  
      // Prepare HTTP post
      PostMethod post = new PostMethod(strURL);
  
      // Request content will be retrieved directly
      // from the input stream
      // Per default, the request content needs to be buffered
      // in order to determine its length.
      // Request body buffering can be avoided when
      // content length is explicitly specified
      post.setRequestEntity(new InputStreamRequestEntity(
              new FileInputStream(input), input.length()));
  
      // Specify content type and encoding
      // If content encoding is not explicitly specified
      // ISO-8859-1 is assumed
      post.setRequestHeader(
              "Content-type", "text/xml; charset=ISO-8859-1");
  
      // Get HTTP client
      HttpClient httpclient = new HttpClient();
  
  
  
      // Execute request
      try {
  
          int result = httpclient.executeMethod(post);
  
          // Display status code
          System.out.println("Response status code: " + result);
  
          // Display response
          System.out.println("Response body: ");
          System.out.println(post.getResponseBodyAsString());
  
  
      }catch (Exception e) {
          e.printStackTrace();
  
      } finally {
          // Release current connection to the connection pool 
          // once you are done
          post.releaseConnection();
      }
  }
  </code></pre>