I am trying to get a DriveItem by the Item Id, however when I attempt this, I get an error saying the no item matching the Id I gave was found. I am using the MSGraph .NET SDK.
var items = await GraphClient.Me.Drive.Special.AppRoot.Children.Request().GetAsync();
var files = items.CurrentPage;
foreach (var file in files)
{
if (file.File.MimeType == "application/json" && filename == file.Name)
{
var itemId = file.Id;
return await GraphClient.Me.Drive.Special.AppRoot.Children[itemId].Request().GetAsync();
}
}
The children
collection expects a file name as the key. Since you have the item id (from file.Id
) you want to use it with the items
collection:
...
return await GraphClient.Me.Drive.Items[itemId].Request().GetAsync();
...