exceção Powershell e sharepoint e updatelistitems ()

2

Eu tenho um problema em que continuo recebendo

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

sempre que eu chamo $service.updatelistitems($listname, $xml) . Eu vasculhei a Net e vi algumas pessoas tendo problemas semelhantes. Minha lista de pontos de compartilhamento é chamada de Autos e tem o campo Title renomeado para Make e um nome de campo adicional Model , ambos os campos de sequência simples.

Alguém sabe por que não consigo atualizar minha lista? Ler a lista funciona bem.

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

    # 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

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

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

    # $list.data.row
    ($list.data.row).count


    # 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>" +
            "</method>"


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

    $ndreturn = $null
    # $ndreturn = $service.updatelistitems($strlistid, $batchelement) # no change using listID
            $ndreturn = $service.updatelistitems($listName, $batchelement)
    
por BenConrad 07.11.2012 / 01:15

0 respostas