I am using Microsoft Graph SDK(C#) V5.56 with App-Only Authentication to upload files to SharePoint. However, when I upload a file, the lastModifiedBy field is always set to “SharePoint App”. I need to set the lastModifiedBy field to a specific user instead of the SharePoint App.
Is there a way to upload a file to SharePoint and have the lastModifiedBy field reflect a user of my choice instead of the SharePoint App while using App-Only Authentication?
This code is working well but it set lastModifiedBy to ‘SharePoint App’ in sharepoint.
public static async Task ReplaceFileInOneDriveAsync(GraphServiceClient gsc, string driveId, string itemId, MemoryStream memoryStream)
{
memoryStream.Position = 0;
Microsoft.Kiota.Abstractions.RequestInformation requestInformations = gsc.Drives[driveId].Items[itemId].Content.ToPutRequestInformation(memoryStream);
requestInformations.URI = new Uri(requestInformations.URI.OriginalString + "[email protected]=replace");
var uploadResult = await gsc.RequestAdapter.SendAsync<DriveItem>(requestInformations, DriveItem.CreateFromDiscriminatorValue);
}
Also I tried some code starting with Users like this but failed.
gsc.Users["[email protected]"].Drives["someID"].....this doesn't contains Items :(
Please suggest!