I am changing the content type of pages using CSOM and would like to preserve the modified by field as it is. The issue is I can set the modified by value to original value, but as soon as I publish the page it changes.
var listItem = pagesLibrary.GetItemById(record.ListItemID);
/// Get the page from the Pages library.
Microsoft.SharePoint.Client.File page = listItem.File;
/// Load the document.
clientContext.Load(page);
//Load the requested list item
clientContext.Load(listItem,
item => item["Title"],
item => item["Author"],
item => item["Editor"],
item => item["Created"],
item => item["Modified"],
item => item["_ModerationStatus"]);
clientContext.ExecuteQuery();
listItem["Author"] = newAuthorFieldUserValue;
listItem["Editor"] = editorUserValue;
listItem.Update();
clientContext.ExecuteQuery();
clientContext.Load(page);
listItem.File.Publish("Published");
clientContext.ExecuteQuery();