首页 > 解决方案 > JAVA Nextcloud API 在使用 https 时抛出 UnknownHostException

问题描述

我尝试用 Java 实现 nextcloud api。我使用了这个 API(https://github.com/a-schild/nextcloud-java-api)并且它是自我解释的,但是我在连接到服务器时遇到了严重的问题。

    public static void main(String[] args) {


    String serverName = "https://<domain>/nextcloud/";
    boolean useHTTPS = true; 
    int port = 443;
    String userName = "test";
    String password = "test";

NextcloudConnector nxt = new NextcloudConnector(serverName, useHTTPS, port, userName, password);
nxt.deleteUser("test2");



    }
    }

我总是得到这个异常:"Exception in thread "main" org.aarboard.nextcloud.api.exception.NextcloudApiException: java.util.concurrent.ExecutionException: java.net.UnknownHostException: https: unknown error"

标签: javacloudnext

解决方案


尝试在 serverName 中不使用协议:

String serverName = "<domain>/nextcloud/";

推荐阅读