Rename a directory over webDav in Java

Owncloud 8.2.1

Hi, I'm using Java to create directories (collections) and put/delete files over WebDAV.

I programmaticaly create a directory TEST, and tried to rename it :slight_smile:
- in the web interface of ownCloud: OK I can rename
- with my java code: I get a 403 Forbidden HTTP response.

My code looks like
sourcePath = "TEST";
destinationPath = "TEST2";
HttpUrl url = new HttpUrl("http://...../remote.php/webdav/" + sourcePath);
url.setUserInfos(... user and password...)
WebdavResource( wdr = new WebdavResource(url);
try {
if (!wdr.exists()) throw new Exception("... doesn't exists");
if (!wdr.moveMethod(destinationPath)) {
throw new Exception(wdr.getStatusCode() + " " + wdr.getStatusMessage());
}
} finally {
wdr.close();
}

I get the 403 Forbidden exception because the moveMethod call doesn't rename (I can confirm by looking in the web interface).

What am I doing wrong ?

Hi! Nobody know how to rename a directory?

Regards,

Hi,

as this is not a Java programming forums you might want to seek support for such programming language specific issues in a forum dedicated to Java...

The question is not java specific, and i can't find my answer in the API. If you find it in the API, please point me to it.

My questions are :slight_smile:
- what URL should I call to rename a directory ?
- Which method (GET, PUT, ......) ?
- Parameters ? new directory name, complete new directory path?
- Is my URL bogus?
- Is ownCloud bogus, allowing renaming in web interface, refusing (403-forbidden) using API?

Hi,

you need to read the WebDAV specifications. There is no API in place here, just plain WebDAV calls to the remote.php/webdav endpoint of ownCloud.