簡體   English   中英

用python中的sud更新sharepoint列表項

[英]Update sharepoint list items with suds in python

我使用以下代碼用python中的suds更新一個共享點列表項:

from suds.sax.element import Element

batch = Element('Batch')
batch.set('OnError','Return')
batch.set('ListVersion','1')

method = Element('Method')
method.set('ID','1')
method.set('Cmd','Update')

field1 = Element('Field').setText(1)
field1.set('Name','ID')

field2 = Element('Field').setText("some text")
field2.set('Name','Title')

method.append(field1)
method.append(field2)
batch.append(method)

updates = Element('ns1:updates')
updates.append(batch)

client.service.UpdateListItems('mmnn', updates)

但是我得到了這個錯誤:

suds.WebFault: Server raised fault: 'Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.'

請注意,我以前使用過此代碼並且它起作用了,但是我不知道為什么現在不起作用。請幫助我。

我使用這種方法將純XML發送到SharePoint Web服務,並且使用SharePoint Web服務文檔,我可以輕松完成我需要做的所有事情:

xml = r"""
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
      <listName>PyTest</listName>
      <updates>
        <Batch OnError="Continue" ListVersion="0">
           <Method ID="1" Cmd="New">
              <Field Name="ID">New</Field>
              <Field Name="Title">{0}</Field>
              <Field Name="Sex">{1}</Field>
              <Field Name="FirstName">{2}</Field>
              <Field Name="LastName">{3}</Field>
              <Field Name="CustomerNum">{4}</Field>
           </Method>
        </Batch>
      </updates>
    </UpdateListItems>
  </soap:Body>
</soap:Envelope>
    """.format(st, sex, fname, lname, costname)

res = client.service.UpdateListItems(__inject={'msg': xml})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM