2017-08-07 58 views
0

我試圖通過Getting access without a user微軟圖形API - /光驅/根/兒童總是空的,即使我在有文件我onedrive

使用微軟圖形API來List Children我建立了我的網址,你會預計:

https://graph.microsoft.com/v1.0/edffcd1c-e5b2-42f2-b554-XXXXXXXXX/drive/root/children

edffcd1c-e5b2-42f2-b554-XXXXXXXXX是誰我想列出文件的用戶ID。

然而,當我把這個我每次都得到一個空的結果:

{ 
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drive/root/children", 
    "value": [] 
} 

這是爲什麼?

更新:似乎這個API只是從Sharepoint帳戶...不是OneDrive帳戶返回文件。我已經可以從Sharepoint API本身訪問Sharepoint文件。有沒有辦法從Microsoft Graph API獲取OneDrive文件?

此網址https://dev.onedrive.com/README.htm似乎說明我們應該能夠做到這一點。

+0

您是否試圖使用'userPrincipalName'而不是'id'?例如:'/ users/rgregg @ contoso.com/drive/root/children'。 –

+0

是的,這只是讓它拋出一個錯誤「資源找不到該段」。我跟微軟談過......這個api只支持通過app-only用戶的sharepoint文件,我猜。總垃圾 –

回答

0

我只是在用戶輸入錯誤:

https://graph.microsoft.com/v1.0/edffcd1c-e5b2-42f2-b554-XXXXXXXXX/drive/root/children

應該是

https://graph.microsoft.com/v1.0/users('edffcd1c-e5b2-42f2-b554-XXXXXXXXX')/drive/root/children

1

您也可以使用此端點 https://graph.microsoft.com/v1.0/me/drive/root/children

,並通過授權標頭持票人標記

+0

是不是我現有的答案更容易,因爲那麼你可以提供用戶ID,並獲得用戶的文件與相同的服務帳戶令牌?無論哪種方式感謝細節。 –

1

有沒有辦法從Microsoft Graph API獲取OneDrive文件?

是的,有是:你必須使用範圍Files.Read.AllFiles.ReadWrite.All

那麼,你的請求/drive/root/children將不再返回一個空數組。