为了账号安全,请及时绑定邮箱和手机立即绑定

HttpURLConnection responseCode 405方法不允许错误

HttpURLConnection responseCode 405方法不允许错误

aluckdog 2021-05-07 10:09:20
我们正在尝试从外部提供商发送请求集成Web api。他们正在使用IP授权,而我们的IP是在其集成系统上定义的。创建HttpUrlConnection时出现405错误,我们无法发送请求此URL。当我们尝试创建具有403错误的主域“ http://api.relateddigital.com ”的HttpUrlConnection时。提供商公司说:“我们对您的IP地址没有任何限制。该错误与您的网络有关。” 我们该如何解决呢?我们的代码: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)    }}
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 628 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信