gpt4 book ai didi

python - 如何在 Sharepoint 中更新文档的元数据? (Linux -> Web 服务 -> Sharepoint)

转载 作者:太空狗 更新时间:2023-10-29 11:30:43 26 4
gpt4 key购买 nike

我设法将文件 (crud PUT khe khe :) 从 Linux 上传到 Sharepoint。文件的绝对路径为:

http://myhost/mysite/reports/2010-04-13/file.txt

现在,我正在尝试向文件中添加一些元数据:

from suds.transport.https import WindowsHttpAuthenticated
url='http://myhost/mysite/_vti_bin/lists.asmx?WSDL'
n=WindowsHttpAuthenticated(username='me',password='password')
from suds.client import Client
c=Client(url,transport=n)

xml="""<Batch OnError='Continue' PreCalc='' ListVersion='0'>
<Method ID='1' Cmd='Update'>
<Field Name='ID'/>
<Field Name='FileRef'>%s</Field>
<Field Name='Jurisdiction'>%s</Field>
</Method>
</Batch>"""
fn = 'http://myhost/mysite/reports/2010-04-13/file.txt'
print c.service.UpdateListItems('reports',xml % (fn,'UK'))

代码返回:

soap:Server

...并且没有发生。我错过了什么吗?还有其他方法吗?

谢谢

最佳答案

找到了! :)

必须使用 DOM 对象而不是纯文本 XML,如下所示:

b = Element("Batch")
b.append(Attribute("OnError","Continue")).append(Attribute("ListVersion","3"))
bm= Element("Method")
bm.append(Attribute("ID","1")).append(Attribute("Cmd","Update"))
bm.append(Element("Field").append(Attribute("Name","ID")).setText(''))
bm.append(Element('Field').append(Attribute('Name','FileRef')).setText('http://.....'))
bm.append(Element('Field').append(Attribute('Name','Jurisdiction')).setText('UK'))
bm.append(Element('Field').append(Attribute('Name','Desk')).setText('Structured Equity Derivatives'))
bm.append(Element('Field').append(Attribute('Name','Business Area')).setText('Back Office'))
bm.append(Element('Field').append(Attribute('Name','Title')).setText('whatever'))
b.append(bm)
u = Element("ns1:updates")
u.append(b)
c.service.UpdateListItems("Reports",u)

现在它完美运行了!

关于python - 如何在 Sharepoint 中更新文档的元数据? (Linux -> Web 服务 -> Sharepoint),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2629918/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com