I have the following PROFIND method / request to the WebDav server:
strQuery = "<?xml version=\"1.0\"?><a:propfind xmlns:a=\"DAV:\">";
strQuery += "<a:prop><a:getcontenttype/></a:prop>";
strQuery += "<a:prop><a:getcontentlength/></a:prop>";
strQuery += "</a:propfind>";
MyCredentialCache = new System.Net.CredentialCache();
MyCredentialCache.Add(new System.Uri(strRootURI), "Basic", new System.Net.NetworkCredential(strUserName, strPassword));
Request = (System.Net.HttpWebRequest)HttpWebRequest.Create(strRootURI);
Request.Proxy = GlobalProxySelection.GetEmptyWebProxy();
Request.Credentials = MyCredentialCache;
Request.Method = "PROPFIND";
bytes = Encoding.UTF8.GetBytes((string)strQuery);
Request.ContentLength = bytes.Length;
RequestStream = Request.GetRequestStream();
RequestStream.Write(bytes, 0, bytes.Length);
RequestStream.Close();
Request.ContentType = "text/xml";
Response = (HttpWebResponse)Request.GetResponse();
ResponseStream = Response.GetResponseStream();
XmlReader = new XmlTextReader(ResponseStream);
while (XmlReader.Read())
{
if (XmlReader.Name == "a:href")
{
XmlReader.Read();
Console.WriteLine("Value: " + XmlReader.Value);
Console.WriteLine("");
XmlReader.Read();
}
}
XmlReader.Close();
ResponseStream.Close();
Response.Close();
The request that I took from MSDN. Am I doing something wrong in a section strQueryor somewhere else?
I get it 400 - Bad request. Please, help.
Thank,
Subhen
source
share