I am trying to delete a list item in a specific folder using SPWeb.ProcessBatchData but no matter what variation of the CAML I use I always end up with the same error message:
<Results><Result ID="" Code="-2130575312"> <ErrorText>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.</ErrorText></Result> </Results>
I tried different variations of the CAML so this is just the one I believe is most accurate:
<?xml version="1.0" encoding="UTF-8"?><Batch OnError="Return" RootFolder="/[documentlibrary]/[folder]"><Method><SetList Scope="Request">[list guid]</SetList><SetVar Name="ID">1</SetVar><SetVar Name="Cmd">Delete</SetVar></Method></Batch>
This is what I tried so far with no success:
- Moving the RootFolder attribute to a SetVar
- Setting SPWeb.AllowUnsafeUpdates to true
- Using a site relative URL in the RootFolder attribute, e.g. /sites/[site]/[web]/[document library]/[folder]
- Opening the SPWeb from an elevated SPSite using SPUserToken.SystemAccount
- Varying the CAML sent to SPWeb.ProcessBatchData
Does anyone have a suggestion on how I can solve this?