1

My app is creating a file (DriveItem) using Graph API. It's using GraphServiceClient from Microsoft.Graph nuget and gets access token with ClientSecretCredential.

Here's the part when the file gets created:

public async Task CreateFile(string driveId, string folderId, string filename, byte[] content)
{
    var driveItem = new DriveItem()
    {
        Name = filename,
        File = new Microsoft.Graph.File()
        {
            MimeType = "application/pdf"
        },
        AdditionalData = new Dictionary<string, object>()
        {
            { "@microsoft.graph.conflictBehavior", "rename" }
        }
    };

    var response = await _client.Drives[driveId].Items[folderId].Children.Request().AddAsync(driveItem);
    await _client.Drives[driveId].Items[response.Id].Content.Request().PutAsync<DriveItem>(new MemoryStream(content));
}

The problem is that the file that's created has the following createdBy identity set:

"createdBy": {
    "application": {
        "id": "[app-id]",
        "displayName": "[app-display-name]"
    },
    "user": {
        "displayName": "SharePoint App"
    }
}

and the name shown in CreatedBy column when viewing files list in Teams is "SharePoint App" instead of my app's display name. When I try to manually set values for CreatedBy property and overwrite user's displayName it simply get ignored.

Am I missing something or is this by design and files created by apps ale always shown as created by "SharePoint App"?

Tomasz T.
  • 321
  • 4
  • 6

2 Answers2

1

According to the documentation createdBy property is read-only.

It will contain identity of the user, device, or application which created the item.

SharePoint App is an inbuilt account used in apps and local to SharePoint only.

It is used when the customer sets up, one App, and provides that App a high level permission to run on the SharePoint Site.

Drive item properties

user2250152
  • 14,658
  • 4
  • 33
  • 57
  • Yeah, that's why if I try to set it it gets ignored, but why does it add this user with "Sharepoint App" displayName instead of using my app's display name? – Tomasz T. Nov 10 '21 at 11:43
  • @TomaszT. "SharePoint App" is an inbuilt account in SharePoint. – user2250152 Nov 10 '21 at 12:01
0

SharePoint App is an inbuilt account used in apps and local to SharePoint only. There is no user associated with the action, in lieu of an actual user identity we show the system-defined SharePoint App as the user. We confirmed it from internally also.

Sayali-MSFT
  • 373
  • 2
  • 6