我尝试使用Webdav.使用curl访问Nextcloud服务器,这工作。
curl -X PROPFIND -u user:pwd https://nextcloudserver.com/remote.php/dav/files/user
使用Javascript,我得到一个503错误
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();
有什么办法吗?
这是为我工作。
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