I am trying to run a batch process to insert items into a list. I am running into an error "Cannot complete action. Please try again." which I believe means that there is something wrong with my batch xml. This is my first time writing a batch for inserting items. I have a batch that deletes items without issue in the same block of code, so I am fairly certain the issue is with the xml.

StringBuilder batchString1 = new StringBuilder();
batchString1.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
batchString1.Append("<ows:Batch OnError=\"Return\">");
string destListID = destList.ID.ToString();
foreach (SPListItem item in items)
    batchString1.Append("<SetList Scope=\"Request\">" + Convert.ToString(destListID) + "</SetList>");
    batchString1.Append("<SetVar Name=\"ID\">New</SetVar>");
    batchString1.Append("<SetVar Name=\"Cmd\">Save</SetVar>");
    batchString1.Append("<SetVar Name=\"urn:schemas-microsoft-com:office:office#Title\">Title here</SetVar>");

Items is just an SPListItemCollection from a different list.

  • Have you checked the ULS logs for more details about the cause of the error? Commented Nov 14, 2013 at 17:52
  • Yes, my understanding was that it pointed to the same thing: at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) at Microsoft.SharePoint.Library.SPRequest.ProcessBatchData(String bstrUrl, String bstrData, ISPDataCallback pResultCallback) at Microsoft.SharePoint.SPWeb.ProcessBatchData(String strBatchData) at CMSync.CMSync.Execute(Guid targetInstanceId) at Microsoft.SharePoint.Administration.SPTimerJobInvokeInternal.Invoke(SPJobDefinition jd, Guid targetInstanceId, Boolean isTimerService, Int32& result)
    – user11457
    Commented Nov 14, 2013 at 17:54

1 Answer 1


Stupid mistake. I never actually closed the xml. Last append is to a batchString variable instead of a batchString1 variable. I have to be less lazy about my naming.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.