C# – Sharepoint Web Services Error GetListItems in Lists.asmx

csharepointweb services

Arrggh. I've seen like 15 examples that say do it like this: SharePoint web services: test if file exists

I'm on the same machine as the SP site, running as the SP and machine admin, I can happily call GetList, GetListCollection and GetWeb on the SiteData web service, but every time I call GetListItems on the Lists web service I get a "Value cannot be null.\nParameter name: g" error.

Nothing in the event viewer.
Nothing in the sharepoint log files that relates
Does anyone know a cause/fix/ where to look?

System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
    System.Xml.XmlNode ndQuery = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "Query", "");
    System.Xml.XmlNode ndViewFields = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "ViewFields", "");
    System.Xml.XmlNode ndQueryOptions = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "QueryOptions", "");

    ndQuery.InnerXml = "<OrderBy><FieldRef Name=\"ID\" /></OrderBy>";


    ndQueryOptions.InnerXml = "<IncludeMandatoryColumns>TRUE</IncludeMandatoryColumns><IncludeAttachmentUrls>FALSE</IncludeAttachmentUrls><Paging />";

    svc.GetListItems(list.ListName, null, ndQuery, ndViewFields, "5", ndQueryOptions, list.WebID.ToString());

Best Answer

You need to pass string.empty as the second paramter (view name) rather than a null value.