ListItem
中的 driveItem
在文档库中始终为null
。如何获取文件的自定义字段?我想构建一个函数来获取文件的内容流和字段。
var client = GetAuthenticatedClient();
var driveItems = await client.Sites[siteId].Drives[driveId].Root.Children.Request().GetAsync();
foreach (var driveItem in driveItems)
{
//ListItem is always null
if (driveItem.ListItem!=null)
{
//get columns
var blabla = driveItem.ListItem.Fields.AdditionalData["blabla"];
}
//SharepointIds is always null too
if (driveItem.SharepointIds != null)
{
}
//get file to download
var file = await client.Drives[driveId].Items[driveItem.Id].Content.Request().GetAsync();
}
答案 0 :(得分:0)
驱动器项的sharepointIds
属性应包含读取列表项所需的信息。
https://docs.microsoft.com/en-us/graph/api/resources/sharepointids?view=graph-rest-1.0
答案 1 :(得分:0)
您需要将ListItem显式添加到DriveItem
var driveItems = await client.Sites[siteId].Drives[driveId].Root.Children.Request().Expand(item => item.ListItem).GetAsync();