我试图在sharepoint网站的特定日历中调用GetListItems。但是,每当我尝试调用GetListItems时,我都会收到错误消息:
Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException'
我的日历位于其网址为:
的sharepoint网站中https://myteam.company.com/sites/TeamSite/Lists/Calendar
我的列表服务的网址是:
https://myteam.company.com/sites/TeamSite//_vti_bin/Lists.asmx
我将getlistitems称为:
appSettings = ConfigurationManager.AppSettings;
credentials = new NetworkCredential(appSettings["Username"], appSettings["Password"]);
var doclist = new Lists() { Credentials = credentials, CookieContainer = new CookieContainer() };
var xmlDoc = new XmlDocument();
XmlElement query = xmlDoc.CreateElement("Query");
XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions");
queryOptions.InnerXml = "<ViewAttributes Scope='Recursive'/>";
XmlNode doc = doclist.GetListItems("Lists", string.Empty, query, viewFields, "0", queryOptions, null);
调用getlistitems方法时总是出错。我的代码有什么问题吗?感谢。
答案 0 :(得分:1)
啊,现在我知道什么是错的;-)你没有瞄准日历!因为日历存在于
之下https://myteam.company.com/sites/TeamSite/Lists/Calendar
您需要调用GetListItems方法,如下所示:
XmlNode doc = doclist.GetListItems("Calendar", string.Empty, query, viewFields, "0", queryOptions, null);