I am trying to call GetListItems in a specific calendar in sharepoint site. However everytime I try to call GetListItems I get an error saying:
Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException'
My calendar is in a sharepoint site whose URL is:
https://myteam.company.com/sites/TeamSite/Lists/Calendar
My url for my lists service is:
https://myteam.company.com/sites/TeamSite//_vti_bin/Lists.asmx
And I call getlistitems as follows:
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);
I always get an error when calling the getlistitems method. Is there anything wrong with my code? Thanks.
Best Answer
ah now i know what's wrong ;-) you aren't targeting the calendar! since the calendar exists under
you need to call the GetListItems method as followed: