Problem: In the foreach below, I have 2 parts.

Part 1 opens an excel File and modifies it Part 2 updates 3 of the ListItem fields

Both parts work individually but with them both enabled, Part 2 fails do to Microsoft.SharePoint.Client.ServerException: 'Version conflict.' understandably

Question: How can I refresh/reload my ListItem?

I tried ListItem.RefreshLoad(); And I looked all over for something along the lines of ListItem.GetFromURL(); but can't seem to find what I'm looking for

            ClientContext cc = new ClientContext(site)
            SecureString pass = new SecureString();
            Web web = cc.Web;

            foreach (char c in "password".ToCharArray())

            cc.Credentials = new SharePointOnlineCredentials("[email protected]", pass);

            Microsoft.SharePoint.Client.List list = web.Lists.GetByTitle("MyLibrary");

            CamlQuery qry = new CamlQuery
                ViewXml = "<View><Query><Where><Contains><FieldRef Name='Active'/><Value Type='Boolean'>1</Value></Contains></Where></Query></View>"
            Microsoft.SharePoint.Client.ListItemCollection listItems = list.GetItems(qry);


            foreach (Microsoft.SharePoint.Client.ListItem listItem in listItems)

                //PART 1
                //Open the file
                //Modify the File
                //Save the file

                //PART 2
                listItem["Updated"] = DateTime.Now;
                listItem["Update_x0020_Duration"] = totalTime;
                listItem["System_x0020_Comment"] = "TestComment";
  • Is your spreadsheet synced to the list you are updating?
    – lazoDev
    Feb 12, 2019 at 20:41
  • Synced to what? Part 1 is all being done in C# also. It was just a lot of bloat code so I didn't put it here. This is running in an SSIS package
    – Jmyster
    Feb 12, 2019 at 21:41
  • Have you tried placing the cc.ExecuteQuery(); outside foreach loop ?
    – Jack Le
    Apr 19, 2019 at 13:14


Your Answer

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

Browse other questions tagged or ask your own question.