2

I have a solution I created a little over a year ago that uses PnP.Core to upload file to a specific folder on SharePoint. It was all well until a couple days ago where that solution started generating error that says To update this folder, go to the channel in Microsoft Teams

I am at a bit of a loss as to why and what is causing this.

Below is a minimal code sample of what I have. I should mention that the folder is getting created but fails with said error when uploading the file to the folder.

Any pointers would be greatly appreciated.

authenticate using officeDev.PnP.Core.AuthenticationManager
...
 Folder Root_Folder = web.GetFolderByServerRelativeUrl(Root_Folder_Relative_Url_Path);

                    //Create new subFolder to load files into
                    string Folder_Name = _Folder_Name;
                    Root_Folder.Folders.Add(Folder_Name);
                    Root_Folder.Update();

                    //Add file to new Folder
                    Folder Subject_Folder = web.GetFolderByServerRelativeUrl(Root_Folder_Relative_Url_Path + "/" + Folder_Name);

                    FileCreationInformation Subject_Result_File = new FileCreationInformation {
                        ContentStream = new MemoryStream(_File_To_Upload),
                        Url = _File_Name,
                        Overwrite = true
                    };

                    Microsoft.SharePoint.Client.File uploadFile = Subject_Folder.Files.Add(Subject_Result_File);
                    Subject_Folder.Update();

                    Client_Ctx.ExecuteQuery();
Bonaii
  • 75
  • 6

1 Answers1

2

Looks like the Update method was the issue. Removing it and just letting the ExecuteQuery handle all the operation fixed it.

Bonaii
  • 75
  • 6
  • Ho man, you just saved me countless hours of trying all kind of crazy stuff. This works for ASP.NET MVC, Web Form, console apps and so on ! Just don't use .Update() I don't even know what's the point. – Antoine Pelletier Nov 22 '22 at 19:22
  • Glad that worked for you too. I believe the update method is suppose to update the specified property and send the update to the server. Not sure why using both the update and excutequery together results in the error. – Bonaii Nov 24 '22 at 00:03