a-schild / nextcloud-java-api

Java api library to access nextcloud features from java applications
GNU General Public License v3.0
72 stars 50 forks source link

Help me! Error connecting and downloading files #43

Closed 1995mars closed 4 years ago

1995mars commented 4 years ago

`package com.vnnet.test.console;

import org.aarboard.nextcloud.api.*;

import java.io.IOException;

public class Test { public static void main(String[] args) { final String baseUrl = "https://tung95.duckdns.org//remote.php/webdav"; try { NextcloudConnector nextcloudConnector = new NextcloudConnector("tung95.duckdns.org", true, 443, "nc_admin", "nextcloudpassword"); nextcloudConnector.downloadFile("/Photos/Coast1.jpg","/home/t94hp/Desktop/"); } catch (IOException e) { e.printStackTrace(); } } } `

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.(I)V at org.apache.http.impl.auth.BasicScheme.authenticate(BasicScheme.java:166) at org.apache.http.impl.auth.HttpAuthenticator.doAuth(HttpAuthenticator.java:233) at org.apache.http.impl.auth.HttpAuthenticator.generateAuthResponse(HttpAuthenticator.java:213) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:262) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:221) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165) at com.github.sardine.impl.SardineImpl.execute(SardineImpl.java:1050) at com.github.sardine.impl.SardineImpl.execute(SardineImpl.java:1019) at com.github.sardine.impl.SardineImpl.exists(SardineImpl.java:1005) at org.aarboard.nextcloud.api.webdav.AWebdavHandler.pathExists(AWebdavHandler.java:86) at org.aarboard.nextcloud.api.webdav.Files.fileExists(Files.java:32) at org.aarboard.nextcloud.api.webdav.Files.downloadFile(Files.java:106) at org.aarboard.nextcloud.api.NextcloudConnector.downloadFile(NextcloudConnector.java:931) at com.vnnet.test.console.Test.main(Test.java:12)

Process finished with exit code 1

a-schild commented 4 years ago

Looks like you use a wrong version of org.apache.commons.codec. Are you using a maven pom file for the dependencies?

With commonds codec 1.11 it should work

1995mars commented 4 years ago

thank you! I have successfully tried

When I add a new user, the result is false, is there any way to fix that?

final String baseUrl = "https://tung95.duckdns.org//remote.php/webdav"; NextcloudConnector nextcloudConnector = new NextcloudConnector("tung95.duckdns.org", true, 443, "nc_admin", "nextcloudpassword");

boolean kq = nextcloudConnector.createUser("qmstung","qmstung"); System.out.println(kq);

a-schild commented 4 years ago

So you can close the issue, right?

1995mars commented 4 years ago

yes. But can you help me on how to add 1 user?

a-schild commented 4 years ago

Look at the included tests

https://github.com/a-schild/nextcloud-java-api/blob/master/src/test/java/org/aarboard/nextcloud/api/TestUserGroupAdmin.java