I'm trying to programmatically upload a file to SharePoint (2016)/ office 365 and modify the Created by /Modified by and also add a history comment along with this operation. The idea is I cannot make those things work together in the same operation.
I can modify the created by with the following code.
uploadFile.ListItemAllFields["Editor"] = userValue.Id; uploadFile.ListItemAllFields["Author"] = userValue.Id;
But in order to add a history comment I must check out/check in the file.
uploadFile.CheckOut(); uploadFile.CheckIn("Just a history comment", CheckinType.OverwriteCheckIn);
This overrides my previous changes and my Author and Editor is set to my account, doesn't matter what I do.
There are other approaches that I'm missing ?