title: HttpURLConnection responseCode 405 method not allowed error
body: <p>We are trying to send request an integration web api from an external provider. They are using IP authorization and our IP is defined on their integration system.</p>
  
  <p>We are having 405 error when create HttpUrlConnection and we can't send request this URL. When we try create HttpUrlConnection with main domain "<a href="http://api.relateddigital.com" rel="nofollow noreferrer">http://api.relateddigital.com</a>" having 403 error.</p>
  
  <p>The provider firm is saying "We haven't any constraint for your IP addresses. The error is associated with your network."
  How can we solve it?</p>
  
  <p>Our Code:</p>
  
  <pre><code>public class Main {
  
      public static void main(String[] args) throws IOException {
          // TODO Auto-generated method stub
  
          final URL url=new URL("http://api.relateddigital.com/resta/api/auth/login");
          final HttpURLConnection connection=(HttpURLConnection)url.openConnection();
          System.out.println("connection.getResponseCode() :: "  + connection.getResponseCode());
          //the output is 405
          connection.setRequestMethod("POST");
          //Exception in thread "main" java.lang.IllegalStateException: connect in progress at sun.net.www.protocol.http.HttpURLConnection.setRequestMethod(Unknown Source)
      }
  
  }
  </code></pre>