2009-09-03 46 views
2

我想從列表中刪除項目,並具有以下XML的Sharepoint使用UpdateListItems WebService的

<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. 

它看起來就像我需要提供fileName而不是僅僅使用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

亞歷克斯的答覆後,我刪除了空間中的URL和已刪除和製表/換行符,因爲這「可能」會導致一個問題:

<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嗎? FileLeafRef?我應該使用文件名嗎?相對路徑?要歸檔的網址?

如果這事這是個圖片Libary

回答

1

這可能是因爲在文件名中的空間和SharePoint無法找到該項目。你有沒有嘗試用%20替換每個空間?

按照MSDN How to: Update List Items文章:

公示UpdateListItems方法在指定項 不存在 靜靜地失敗。

如果這不起作用,你可以嘗試Batch元素指定ListVersionViewName屬性。每個example我見過指定這些。

+0

在正常列表中刪除時,我不需要列表版本或ViewName。無論如何,我不確定要放什麼。現在更新主要問題... – Jack 2009-09-03 15:25:01

+0

我已經嘗試了視圖和列表版本,沒有雪茄。 – Jack 2009-09-03 15:50:08

+0

它仍然看起來像文件名中有空格(見日期之後)。同樣爲了回答更新中的問題,您需要完整的網址。 – 2009-09-03 16:44:52

0

我最近遇到了同樣的問題來了,你需要包括對要刪除的項目,以及爲以下的ID和相對路徑:

<Batch OnError="Return"> 
    <Method ID="1"> 
    <Field Name="ID">123456</Field> 
    <Field Name="FileRef">sites/library/folderNameOrFileName</Field> 
    </Method> 
</Batch> 
相關問題