0

I try to access a Nextcloud server using Webdav. Using curl this works:

curl -X PROPFIND -u user:pwd https://nextcloudserver.com/remote.php/dav/files/user

Using Javascript this I get a 503 error

const url = "https://nextcloudserver.com/remote.php/dav/files/user/"
var xhr = new XMLHttpRequest();
xhr.open('PROPFIND', url, true);
xhr.setRequestHeader("Authorization", "Basic " + btoa("username:pwd"));
xhr.withCredentials=true;
xhr.send();

Any idea?

Okilele
  • 85
  • 1
  • 5

1 Answers1

1

this is working for me:

const url = "https://nextcloudserver.com/public.php/webdav/";
var objHTTP = new XMLHttpRequest();
objHTTP.open('PROPFIND', url, true);
objHTTP.setRequestHeader("OCS-APIRequest","true");
objHTTP.setRequestHeader("Authorization", "Basic " + Base64.encode("username:password"));
objHTTP.onreadystatechange = function() {
    if (objHTTP.readyState == XMLHttpRequest.DONE) {
        console.log(objHTTP.responseText);
    }
}
objHTTP.send();

Regards, Roberto