WebDAV get free space info

落花浮王杯 提交于 2019-12-23 16:27:59

问题


I'm working with Yandex Disk API (http://api.yandex.com/disk/doc/dg/reference/propfind_space-request.xml). Having trouble with adding property in the request body (quota-available-bytes and quota-used-bytes)

public static string SpaceInfo(string path)
{
    // Authorization.
    HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create("https://webdav.yandex.ru/");
    webReq.Accept = "*/*";
    webReq.Headers.Add("Depth: 0");
    webReq.Headers.Add("Authorization: OAuth " + token);
    webReq.Method = "PROPFIND";

    // Adding data in body request.
    string inputData = @"<D:propfind xmlns:D=""DAV:""><D:prop><quota-available-bytes/></D:prop></D:propfind>";
    byte[] buffer = new ASCIIEncoding().GetBytes(inputData);

    webReq.ContentType = "text/xml; encoding='utf-8";
    webReq.ContentLength = buffer.Length;

    try
    {
        HttpWebResponse resp = (HttpWebResponse)webReq.GetResponse();
        StreamReader sr = new StreamReader(resp.GetResponseStream());
        string dinfo = sr.ReadToEnd();

        return dinfo;
    }
}

I don't get any response, maybe i can use another method? What should i do? Thanks!


回答1:


quota-available-bytes should use same namespace "D"



来源:https://stackoverflow.com/questions/18705670/webdav-get-free-space-info

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!