本文介绍了WebDAV获得免费空间信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Yandex磁盘API( http://api.yandex.com/disk/doc/dg/reference/propfind_space-request.xml ).无法在请求正文中添加属性( quota-available-bytes 和 quota-used-bytes )
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!
推荐答案
quota-available-bytes应该使用相同的命名空间"D"
quota-available-bytes should use same namespace "D"
这篇关于WebDAV获得免费空间信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!