Sharepoint 使用 UpdateListItems WebService 从列表中删除项目
我正在尝试从列表中删除一个项目并具有以下 xml
<Batch PreCalc='TRUE' OnError='Continue'>
<Method ID='1' Cmd='Delete'>\
<Field Name='ID'>185</Field>
</Method>
</Batch>
这将返回以下错误
0x81020030 - Invalid file name
The file name you specified could not be used. It may be the name of
an existing file or directory, or you may not have permission to
access the file.
看起来我需要提供文件名而不仅仅是使用 ID。到目前为止,我的尝试都失败了。
更新
我认为 XML 需要采用以下格式:
<Batch PreCalc='TRUE' OnError='Continue'>
<Method ID='1' Cmd='Delete'>
<Field Name='ID'>185</Field>
<Field Name="FileRef">http://sharepoint.mycompany.com/testsite/lib/flying spider 2009-09-03 P.jpg</Field>
</Method>
</Batch>
不会引发任何错误,但不会删除任何内容。
更新 2
在 Alex 回复后,我删除了网址中的空格,并删除了制表符/换行符,因为这“可能”会导致问题:
<Batch PreCalc='TRUE' OnError='Continue'>
<Method ID='1' Cmd='Delete'>
<Field Name='ID'>185</Field>
<Field Name="FileRef">http://sharepoint.mycompany.com/testsite/lib/flying%20spider%202009-09-03 P.jpg</Field>
</Method>
</Batch>
再次不会抛出任何错误。
我应该使用 FileRef 吗?文件叶参考?我应该使用文件名吗?相对路径?文件的 URL?
如果这很重要,那么这是一个图片库
I am trying to delete an item from a list and have the following xml
<Batch PreCalc='TRUE' OnError='Continue'>
<Method ID='1' Cmd='Delete'>\
<Field Name='ID'>185</Field>
</Method>
</Batch>
This is returning the following error
0x81020030 - Invalid file name
The file name you specified could not be used. It may be the name of
an existing file or directory, or you may not have permission to
access the file.
It looks like I need to provide the fileName rather than just using the ID. My attempts to do this have failed so far.
Update
I think the XML needs to be in the following format:
<Batch PreCalc='TRUE' OnError='Continue'>
<Method ID='1' Cmd='Delete'>
<Field Name='ID'>185</Field>
<Field Name="FileRef">http://sharepoint.mycompany.com/testsite/lib/flying spider 2009-09-03 P.jpg</Field>
</Method>
</Batch>
No error is thrown but nothing is being deleted.
Update 2
After Alex reply I removed the spaces in the url and have removed and tabs/ newlines as this "may" cause a problem:
<Batch PreCalc='TRUE' OnError='Continue'>
<Method ID='1' Cmd='Delete'>
<Field Name='ID'>185</Field>
<Field Name="FileRef">http://sharepoint.mycompany.com/testsite/lib/flying%20spider%202009-09-03 P.jpg</Field>
</Method>
</Batch>
Again no error is thrown.
Should I be using FileRef? FileLeafRef? Should I me using the file name? relative path? URL to file?
If this matters this is a Picture Libary
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这可能是因为文件名中有空格并且 SharePoint 找不到该项目。您是否尝试过用
%20
替换每个空格?根据 MSDN 如何:更新列表项文章:
如果这不起作用,您可以尝试在
Batch
元素上指定ListVersion
和ViewName
属性。我见过的每个示例都指定了这些。This is probably because there are spaces in the filename and SharePoint can't find the item. Have you tried replacing each space with
%20
?According to the MSDN How to: Update List Items article:
If this doesn't work you could try specifying the
ListVersion
andViewName
attributes on theBatch
element. Every example I've seen specifies these.也试试这个,
从 SharePoint 列表中删除项目及更多< /a>
Try this too,
Delete item from SharePoint List and more
我最近遇到了同样的问题,您需要包含要删除的项目的相对路径以及 id,如下所示:
I recently came across the same problem, you need to include the relative path to the item you are deleting as well as the id as below:
您需要先通过 GetListItems 获取 ID,然后使用该 ID 作为主要事件 ID 进行删除:
然后该 ID 包含节点 InnerXML,这里是 xml 示例:
属性“ows_ID”是您可以用于删除的 ID!
以下是 GetListItems 详细信息的 MS 链接:
https:// /learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-services/ms772599(v=office.12)
You need get the ID first by GetListItems, then use this ID as primary event ID to Delete:
Then the ID contain the node InnerXML, here is the xml sample:
the attribute "ows_ID" is the ID you can use for delete!
Here is the MS link for GetListItems Details:
https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-services/ms772599(v=office.12)