簡體   English   中英

使用.NET SDK按路徑獲取Microsoft Graph Drive項目

[英]Getting Microsoft Graph Drive items by path using the .NET SDK

文檔所述 ,使用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)來做到這一點?

這是這樣的:

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

僅使用普通路徑。 不要包含“:”,也不要包含“ / drive / root:/”。

很明顯,現在我看到了...

為了將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/zh-cn/graph/graph-explorer

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM