Reputation: 46
I want to use graph api to get someone's onedrive for business file size.
First I need get users' drive id ,but when i use below script to get drive id, return itemnot found.
The account do have onedrive for business license.
And the api assigned below permissions.
AllSites.Read
Files.Read
Files.Read.All
Files.ReadWrite
Files.ReadWrite.All
Sites.Read.All
Sites.ReadWrite.All
Sites.Search.All
User.Read
User.Read.All
User.ReadWrite.All
$url = "https://graph.microsoft.com/v1.0/users/[email protected]/drive"
$myReport2 =Invoke-RestMethod -UseBasicParsing -Headers $headerParams -Uri $url -Method Get -Verbose
Invoke-RestMethod : {
"error": {
"code": "itemNotFound",
"message": "The resource could not be found.",
"innerError": {
"request-id": "c0e7fd32-169e-4167-90d4-7adc3947cfda",
"date": "2020-03-18T07:09:22"
}
}
}
Upvotes: 0
Views: 758
Reputation: 46
It's graph api by design problem.
Only Onedrive site admin can use graph api get onedrive file infomation.
Use below command add graph api user to onedrive site admin.
$SiteUrl = "https://tenant-my.sharepoint.com/personal/username_domain_com/"
connect-sposervice -Url "https://tenant-admin.sharepoint.com/" -Credential Get-Credential
$sSecondaryODFBAdmin ="[email protected]"
Set-SPOUser -Site $SiteUrl -LoginName $sSecondaryODFBAdmin -IsSiteCollectionAdmin $true
Upvotes: 0