The following code compiles with no errors:

        ListsWebServices.Lists listService = new ListsWebServices.Lists();
        listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
        listService.Url = "http://toplevel/OC/coldrooms/_vti_bin/lists.asmx";
        System.Xml.XmlNode ndListView = listService.GetListAndView("Test", "");
        string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;
        string strViewID = ndListView.ChildNodes[1].Attributes["Name"].Value;
        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
        System.Xml.XmlElement batchElement = doc.CreateElement("Batch");
        batchElement.SetAttribute("OnError", "Continue");
        batchElement.SetAttribute("ListVersion", "1");
        batchElement.SetAttribute("ViewName", strViewID);
        batchElement.InnerXml = "<Method ID='1' Cmd='New'>" +
        "<Field Name='ID'>New</Field>" +
        "<Field Name='User'>MR ANDERSON</Field>" +
            listService.UpdateListItems(strListID, batchElement);
        catch (Exception ex)

But does not add any new item to the List, I have confirmed that it gets the right GUID's by opening the list in sharepoint designer and cross referencing. Any advice as to where I am going wrong would be greatly appreciated.


I found the answer, turns out that Internal field names can and often are separate from External Field names. In short the created name "User" was not in fact called "User", it was something else.


Try passing "" as the view guid like: batchElement.SetAttribute("ViewName", "");

Also check that : 1. what is the type of the USER filed? 2. Are there any mandatory fields in the list?

  • Hi there, User field is of "Single line of text" and is Mandatory There are no other created fields. I've also changed the ViewName Attribute to "", however am getting the same result.
    – beuy
    Nov 26 '10 at 7:25
  • Try to pass the list name and not the list GUID, like: listService.UpdateListItems("Test", batchElement);
    – Vivek
    Nov 26 '10 at 8:05
  • Changed the line to: listService.UpdateListItems("Test", batchElement);, no change
    – beuy
    Nov 26 '10 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy