Checking Sharepoint UpdateListItems Xml Result

16 12 2008

Here’s a code snippet for checking the Xml result returned from Sharepoints UpdateListItems() Lists webservice method.

private static KeyValuePair<int, string> CheckListUpdateResults(XmlNode resultsNode)
{
	if (resultsNode == null) return new KeyValuePair<int, string>(0, "Null results node supplied");
	XmlNamespaceManager ns = new XmlNamespaceManager(resultsNode.OwnerDocument.NameTable);
	ns.AddNamespace("sp", resultsNode.NamespaceURI);

	var errorCode = resultsNode.SelectSingleNode("//sp:ErrorCode", ns).InnerText;
	if (errorCode == "0x00000000")
	{
		// grab the list item ID
		var owsID = resultsNode.SelectSingleNode("//@ows_ID").Value;
		return new KeyValuePair<int, string>(Convert.ToInt32(owsID), null);
	}

	var errorText = resultsNode.SelectSingleNode("//sp:ErrorText", ns).InnerText;
	var result = new KeyValuePair<int, string>(0, string.Format("Error {0}, {1}",
								errorCode ?? "n/a",
								errorText ?? "n/a"));
	return result;
}




Sharepoint UpdateListItems Webservice Error Message

16 12 2008

Recently, calling Sharepoint Lists Webservice method UpdateListItems() I was getting back an error message of “One or more field types are not installed properly”.

After head scratching for a while I remembered that some of the list columns had spaces in, so I duly replaced spaces on the column names of my CAML query with _x0020_ and tried again. Same problem, I then came aross a post which mentioned that even if you rename columns, they retain their original internal names and these are the names you must reference in your CAML.

Now, not remembering the original column names, I fired up U2U’s CAML Query Builder, pointed it at the list and it conveniently spits out a CAML query using the internal names of the list columns.

Looking at the Query Builder output, I also notice that there are length constraints on internal column names.