Sample code for WebDAV PROPFIND

本小妞迷上赌 提交于 2019-12-02 17:51:48

问题


Is there any site or some one can provide me a sample PROFIND request please.

I tried the PROFIND code sample from MSDN but getting 400 Bad request.

Unable to understand why this is happening.

Previously posted the question at Getting 400 Bad request from WebDav Server

Any suggestions will be greatly helpfull.

Edit

@Julian,

Have updated my request body to the following:

 strBody = "<?xml version='1.0' encoding='utf-8'?>"
                 + "<propfind xmlns='DAV:'>"
                 + "<allprop/>"
                + "</propfind>";

as explained at RFC 4918, Section 9.1

But I am still getting the 400 Bad request Error. M I missing any Headers . Please suggest I am setting the following Header Information:

 System.Net.HttpWebRequest Request;
 Request.Credentials = MyCredentialCache;
 Request.Method = "PROPFIND";

 bytes = Encoding.UTF8.GetBytes((string)strBody);
 Request.ContentType = "text/xml";

Do I need to set or specify something additional. The full code is in my Previosu Question.

Thanks,

Subhen


回答1:


Ok I was missing the Depth Header and for that reason the webserver was returning Method Not allowed error.

MSDN clearlystates that A PROPFIND with depth value of "infinity" is not supported in the public store that is accessible to MAPI clients such as Microsoft Outlook.

And the Bad request 404 error was generated because I was not using proxy. So What I did I commented the line which was not using any proxy and added the Depth Header.

 // Request.Proxy = GlobalProxySelection.GetEmptyWebProxy();
Request.Headers.Add("Depth", "1");


来源:https://stackoverflow.com/questions/3137995/sample-code-for-webdav-propfind

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