代码之家  ›  专栏  ›  技术社区  ›  dot

MS Graph Explorer:如何使用GraphServiceClient对象获取特定用户的驱动器

  •  0
  • dot  · 技术社区  · 3 年前

    试图弄清楚如何通过编程为特定用户获取特定文件夹。 在Graph Explorer中,我可以做这样的事情来获取驱动器ID

    https://graph.microsoft.com/v1.0/users/<specificUsersGuid>/drive/root/children
    

    然后我继续这个请求:

    https://graph.microsoft.com/v1.0/users/<specificUserGuid>/drive/items/<driveId>/children
    

    我试图弄清楚如何使用c#以编程方式实现这一点。我找到了这篇文章: https://docs.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&tabs=http#examples

    我猜,它有一个如何为当前用户使用“me”语法的例子?但我需要一种方法来指定用户。

    任何提示都将不胜感激。

    谢谢。

    0 回复  |  直到 3 年前
        1
  •  0
  •   user2250152    3 年前

    如果您正在使用Graph API SDK,则可以使用 Users["{id}"] 得到 GraphServiceUsers 请求生成器。

    第一个请求

    https://graph.microsoft.com/v1.0/users/<specificUsersGuid>/drive/root/children
    

    可以写成

    var driveItemChildrenCollectionPage = await graphClient.Users["specificUsersGuid"].Drive.Root.Children.Request().GetAsync();
    

    第二个请求

    https://graph.microsoft.com/v1.0/users/<specificUserGuid>/drive/items/<driveId>/children
    

    作为

    var result = await client.Users["specificUsersGuid"].Drive.Items["driveItemId"].Children.Request().GetAsync();