Server Exception : Cannot invoke method or retrieve property from null object. Object returned by the following call stack is null. \“File\r\n\”

sharepoint.stackexchange https://sharepoint.stackexchange.com/questions/191605

  •  11-10-2020
  •  | 
  •  

Question

So I have a ABC(example.com/ABC) folder in my server so if I edit some file which is inside that ABC folder it'll edit without any exceptions. I have another folder inside that ABC folder (example.com/ABC/XYZ). So if I edit the file which is inside my XYZ folder it is throwing this exception after ExecuteQuery();

item.File.Publish(publishComment);
SharePointTools.ClientContext.ExecuteQuery();

.

 public static bool EditPage(SPClient.ListItem item, string pageTitle, string pageContent, string publishComment)
        {
            var pageEdited = false;
            try
            {
                item["Title"] = pageTitle;
                item["PublishingPageContent"] = pageContent;
                item.Update();
                SharePointTools.ClientContext.ExecuteQuery();
                item.File.Publish(publishComment);
                SharePointTools.ClientContext.ExecuteQuery();
                pageEdited = true;
            }
            catch (Exception ex)
            {
                pageEdited = false;
            }
            return pageEdited;
        }

Can someone help me with this.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top