【问题标题】:Office365 graph api get onedrive for business ID return itemNotFoundOffice365 graph api get onedrive for business ID return itemNotFound
【发布时间】:2020-03-23 17:32:11
【问题描述】:

我想使用图形 api 来获取某人的业务文件大小的 onedrive。
首先我需要获取用户的驱动器 ID,但是当我使用下面的脚本获取驱动器 ID 时,返回 itemnot found。
该帐户确实有 onedrive 的营业执照。
并且 api 分配了以下权限。
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/xxx@domain.com/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"
    }
  }
}

【问题讨论】:

  • 您提出的问题需要更多信息。请添加对您正在采取的行动和您希望实现的目标的清晰描述,以及您想要实现此目标的代码。这样我们或许可以为您提供一个好的解决方案。

标签: powershell office365 onedrive office365api


【解决方案1】:

这是设计问题的图形 api。
只有 Onedrive 站点管理员可以使用图形 api 获取 onedrive 文件信息。
使用以下命令将图形 api 用户添加到 onedrive 站点管理员。

$SiteUrl = "https://tenant-my.sharepoint.com/personal/username_domain_com/"
connect-sposervice -Url "https://tenant-admin.sharepoint.com/" -Credential Get-Credential
$sSecondaryODFBAdmin ="graphapi@tenant.onmicrosoft.com"
Set-SPOUser -Site $SiteUrl -LoginName $sSecondaryODFBAdmin -IsSiteCollectionAdmin $true

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多