views:

1935

answers:

4

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

+1  A: 

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:

Posting the UpdateListItems method silently fails if a specified item does not exist.

If this doesn't work you could try specifying the ListVersion and ViewName attributes on the Batch element. Every example I've seen specifies these.

Alex Angas
when deleting in a normal list I do not need the List Version or ViewName. I am unsure what to put here anyway. Updating the main question now...
Jack
I have tried with both a view and list version and no cigar.
Jack
It still looks like there are spaces in the filename (see after the date). Also to answer the question in your update you will need to full URL.
Alex Angas
A: 

Try this too,

Delete item from SharePoint List and more

sara
A: 

I'm getting the same error trying to update a list item. The 0x81020030 code gets a mere 3 hits on Bing, and this is one of them. I've tried every variant I can think of based on your attempts above.

One thing that may be different in my case: the item I am trying to update is a copy of another item created using the Copy Web Service. Maybe having a _CopySource value prevents an update of the item directly?

M.

Marc D Anderson
A: 

Were you able to get this one working? I have the same problem: I am deleting a document from a document list and I get back 0x00000000 but with no row data. When I go back to SharePoint, the document is still there.

Mark