Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过代理[Java]访问Bitbucket API(JSON)_Java_Json_Proxy_Bitbucket - Fatal编程技术网

通过代理[Java]访问Bitbucket API(JSON)

通过代理[Java]访问Bitbucket API(JSON),java,json,proxy,bitbucket,Java,Json,Proxy,Bitbucket,我试图通过Java访问Bitbucket API以获取JSON文件。 但不幸的是,我必须通过代理路由请求才能访问它。这几天我什么都试过了,但都没用。你们两个都能帮我吗?以下是我使用的代码: Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("xxx-proxy.com", 8080)); Authenticator.setDefault(new Authenticator() { @

我试图通过Java访问Bitbucket API以获取JSON文件。 但不幸的是,我必须通过代理路由请求才能访问它。这几天我什么都试过了,但都没用。你们两个都能帮我吗?以下是我使用的代码:

Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("xxx-proxy.com", 8080));
      Authenticator.setDefault(new Authenticator() {

            @Override
            protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication("xxxx", "xxxx".toCharArray());
            }
    });
      URL url = new URL("https://xxxxx.com/rest/api/1.0/projects");
      HttpURLConnection uc = (HttpURLConnection)url.openConnection(proxy);
      uc.connect();
但我有一个例外:无法通过代理进行隧道。代理返回“HTTP/1.1 403禁止”对我来说,这听起来像是代理未连接,因为它在我只想使用google.com时工作

我非常感谢你的帮助


谢谢大家!

粘贴您迄今为止尝试过的代码以及您遇到的错误。人们将能够在这些信息上提供帮助。谢谢你的建议,我在我认为可能出错的地方添加了代码!:)