Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got an issue where I keep getting

"Exception calling "UpdateListItems" with "2" argument(s): "Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown."

whenever I call $service.updatelistitems($listname, $xml). I've scoured the Net and see some people having similar issues. My sharepoint list is called Autos and has the Title field renamed to Make and an additional field name Model, both simple string fields.

Does anybody know why I can't update my list? Reading the list works just fine.

    $uri = 'http://myServerName/sandbox/_vti_bin/lists.asmx?wsdl'
    $listName = 'Autos'  # car list

    # Create the service            
    $service = New-WebServiceProxy -Uri $uri  -Namespace SpWs  -UseDefaultCredential

    # Create xml query to retrieve list.
    $xmlDoc = new-object System.Xml.XmlDocument
    $query = $xmlDoc.CreateElement("Query")
    $viewFields = $xmlDoc.CreateElement("ViewFields")
    $queryOptions = $xmlDoc.CreateElement("QueryOptions")
    $query.set_InnerXml("FieldRef Name='Full Name'")
    $rowLimit = "1000"

    $list = $null
    $service = $null

        $service = New-WebServiceProxy -Uri $uri  -Namespace SpWs  -UseDefaultCredential
        Write-Error $_ -ErrorAction:'SilentlyContinue'

    # Now, we use the service object to retrieve the list.
    if($service -ne $null){
            $list = $service.GetListItems($listName, "", $query, $viewFields, $rowLimit, $queryOptions, "")
            Write-Error $_ -ErrorAction:'SilentlyContinue'

    # $

    # Get name attribute values (guids) for list and view
    $ndlistview = $service.getlistandview($listname, "")
    $strlistid = $ndlistview.childnodes.item(0).name
    $strviewid = $ndlistview.childnodes.item(1).name

    # Create an xmldocument object and construct a batch element and its attributes.
    $xmldoc = new-object system.xml.xmldocument

    # note that an empty viewname parameter causes the method to use the default view
    $batchelement = $xmldoc.createelement("Batch") # Capital B
    $batchelement.setattribute("onerror", "continue")
    $batchelement.setattribute("listversion", "1")
    $batchelement.setattribute("viewname", $strviewid)

    # Specify methods for the batch post using caml. to update or delete, specify the id of the item,
    # and to update or add, specify the value to place in the specified column
    $xml = ""
    $xml += "<method ID='1' cmd='Update'>" +
            "<field name='ID'>1</field>" +
            "<field name='Title'>Subaru</field>" +
            "<field name='Model'>Outback</field>" +

    # Set the xml content
    $batchelement.innerxml = $xml

    $ndreturn = $null
    # $ndreturn = $service.updatelistitems($strlistid, $batchelement) # no change using listID
            $ndreturn = $service.updatelistitems($listName, $batchelement)
share|improve this question
I did not realize XML is case sensitive, this works: $xml += "<Method ID='1' Cmd='Update'>" + "<Field Name='ID'>1</Field>" + "<Field Name='Title'>Subaru</Field>" + "<Field Name='Model'>Outback</Field>" + "</Method>" Ben – BenConrad Nov 8 '12 at 14:03
You should be able to add an answer to your own question then accept the answer – uSlackr Nov 27 '12 at 21:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.