首页 文章

使用.NET SDK按路径获取Microsoft Graph Drive项目

提问于
浏览
1

因为它是documented,使用Microsoft Graph REST API,您可以(以及其他选项)通过Id或Path获取项目 . 这正常,正如预期的那样:

GET /me/drive/items/{item-id}/children
GET /me/drive/root:/{item-path}:/children

使用.NET SDK,我可以通过Id获取文件夹(即第一种情况):

var items = await graphClient.Me.Drive.Items[myFolderId].Children.Request().GetAsync();

但是,我找不到(使用.NET SDK)做同样的事情,但指定路径而不是Id(即第二种情况) .

我不想找到我已经知道的路径的Id,来创建它的请求 . 对?

我担心使用当前的SDK(Microsoft Graph Client Library 1.1.1)无法做到这一点?

2 回答

  • 1

    这是如何:

    var items = await graphClient.Me.Drive.Root
                      .ItemWithPath("/this/is/the/path").Children.Request().GetAsync();
    

    仅使用普通路径 . 不要包含“:”,也不要包含“/ drive / root:/” .

    很明显,现在我看到了......

  • 3

    要将Microsoft Graph SDK与Office365 for Business / Sharepoint / Teams一起使用,请将代码中的“Me”替换为“Groups [teamId / groupId]” .

    像这样:

    var items = await graphClient.Groups["teamId/groupId"].Drive.Root
        .ItemWithPath("/this/is/the/path").Children.Request().GetAsync();
    

    如果您使用Microsoft Graph Explorer,则可以找到您的团队/组ID:https://developer.microsoft.com/en-us/graph/graph-explorer

相关问题