I am trying to delete a document, using the sharepoint webservice, if someone uploads a document and then hits cancel. I have created the following function
function DeleteDocument(libraryName, ID)
{
debug.log('DeleteDocument (Entry) libraryname = '+libraryName+' ID='+ID);
var batch =
"<Batch OnError='Continue'> \
<Method ID='1' Cmd='Delete'> \
<Field Name='ID'>" + ID + "</Field> \
</Method> \
</Batch>";
var soapEnv =
"<?xml version='1.0' encoding='utf-8'?> \
<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>"+libraryName+"</listName> \
<updates> \
" + batch + "</updates> \
</UpdateListItems> \
</soap:Body> \
</soap:Envelope>";
debug.log(soapEnv);
$.ajax({
url: "http://<serverandsite>/_vti_bin/lists.asmx",
beforeSend: function(xhr) {
xhr.setRequestHeader("SOAPAction",
"http://schemas.microsoft.com/sharepoint/soap/UpdateListItems");
},
type: "POST",
dataType: "xml",
data: soapEnv,
complete: function(xData, status){
alert(xData.responseText);
debug.log('xData response = ' + xData.responseText);
debug.log('status response = ' + status);
},
contentType: "text/xml; charset=utf-8"
});
}
When i run it i get
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.
Does anyone have any ideas why this might be failing. I am running the code against a standard document library.
I have tried it against checked-in and checked out files and get the same message. I need this to run against documents that are checked out, in fact they will never have been checked in, so i have no idea how i could work out the fileref