【问题标题】:How to get Sharepoint ListItem on DriveItem with Microsoft Graph API c# SDK如何使用 Microsoft Graph API c# SDK 在 DriveItem 上获取 Sharepoint ListItem
【发布时间】:2019-10-17 20:35:08
【问题描述】:

driveItem 中的ListItem 在文档库中始终为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();
}

【问题讨论】:

    标签: c# sharepoint microsoft-graph-api microsoft-graph-sdks


    【解决方案1】:

    您需要将 ListItem 显式添加到 DriveItem

    var driveItems = await client.Sites[siteId].Drives[driveId].Root.Children.Request().Expand(item => item.ListItem).GetAsync();
    

    【讨论】:

      【解决方案2】:

      驱动器项的sharepointIds 属性应包含读取列表项所需的信息。

      https://docs.microsoft.com/en-us/graph/api/resources/sharepointids?view=graph-rest-1.0

      【讨论】:

      • 正如我在示例代码中所写,SharepointIds 属性也始终为空...
      • @J.Y.您需要明确选择要返回的 SharepointIds 属性。
      猜你喜欢
      • 1970-01-01
      • 2021-10-14
      • 2022-01-15
      • 2019-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-16
      • 1970-01-01
      相关资源
      最近更新 更多