【问题标题】:Cannot find workbook relationship in a shareddriveitem/driveitem resource with Microsoft Graph API无法使用 Microsoft Graph API 在 shareddriveitem/driveitem 资源中找到工作簿关系
【发布时间】:2023-04-11 10:29:01
【问题描述】:

使用 Microsoft Graph API,我可以通过 https://graph.microsoft.com/v1.0/me/drive/items/{id}/ 从存储在我的企业 OneDrive 上的驱动项获取工作簿资源。

但是,如果另一个用户将工作簿共享给组织并且我通过 https://graph.microsoft.com/v1.0/shares/{EncodedSharingURL}/driveitem/ 访问它,我将无法获取工作簿资源。

尝试访问共享驱动项的工作簿时的响应如下:

"message": "Unable to find target address"

驱动项返回的 JSON 在这两种情况下看起来非常相似。有什么不同?

【问题讨论】:

  • 我也在努力解决这个问题
  • 很高兴知道,一年多过去了,这仍然是一个谜,微软还没有更新他们的文档。
  • 我偶然发现了同样的问题。它不能解决我自己的问题,但似乎我们仍然能够通过以下链接获取文件的全部内容:https://graph.microsoft.com/v1.0/shares/{EncodedSharingURL}/driveitem/content
  • 也许这可以帮助你:stackoverflow.com/a/71109776/7448794

标签: excel api microsoft-graph-api


【解决方案1】:

要直接访问文件,您需要驱动器 ID 和文件 ID,其中包含 https://graph.microsoft.com/v1.0/shares/{EncodedSharingURL}/driveitem/ 响应:

driveID = driveitem.ParentReference.DriveId

fileID = driveitem.ParentReference.Id

像这样使用它: https://graph.microsoft.com/v1.0/drives(driveID)/items(fileID)/workbook/worksheets

这里是: https://docs.microsoft.com/en-us/graph/api/drive-sharedwithme?view=graph-rest-1.0&tabs=http#remarks

【讨论】:

  • 我们在此不鼓励“仅链接答案”,因为当链接失效时,您的答案将变得毫无价值。请复制这些链接中与解决此确切问题相关的任何信息。我通常将源材料的链接留在底部。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-23
相关资源
最近更新 更多