如何获取参考附件的url?

How to get the url of the reference attachment?

我正在使用 Microsoft Graph。当我使用

GET /me/messages/{messageId}/attachments

如果有通过 OneDrive 或 SharePoint 共享的附件,@odata.type 将为 #microsoft.graph.referenceAttachment。而且体积非常小,因为它不是真正的文件。

 {
  "@odata.type": "#microsoft.graph.referenceAttachment",
  "id": "AAMkADBlZTUwNTkxLWVmODgtNDVhNC1iZjhlLTdjNjA1ODZlMDI5MgBGAAAAAACUbnk-iwQZRbXMgkfKtmYhBwCpTc-InBsuTYwTUBb_VIb4AAAAAAEMAACpTc-InBsuTYwTUBb_VIb4AAEBiQutAAABEgAQAMqgyfrokPFCrRfUa2mrxxM=",
  "name": "word.docx",
  "contentType": null,
  "size": 4601,
  "isInline": false
}

有什么办法可以得到这个附件的实际 url 可以在浏览器中打开吗?谢谢

v1.0 版本对 referenceAttachment 的支持非常 有限。我的意思是,除了承认它们的存在之外,你对它们无能为力。

然而,测试版支持更丰富的 referenceAttachment 对象。当我遇到 referenceAttachment 时,我调用使用 beta 端点检索附件,确实 有指向实际文件的链接:

{
  "contentType": "string",
  "id": "string (identifier)",
  "isFolder": true,
  "isInline": true,
  "lastModifiedDateTime": "String (timestamp)",
  "name": "string",
  "permission": "string",
  "previewUrl": "string",
  "providerType": "string",
  "size": 1024,
  "sourceUrl": "string",
  "thumbnailUrl": "string"
}

你要的是 referenceAttachment resourcesourceUrl 属性:

URL to get the attachment content. If this is a URL to a folder, then for the folder to be displayed correctly in Outlook or Outlook on the web, set isFolder to true. Required.

但是 属性 不适用于 v1.0 API 版本,需要使用 beta 端点:

https://graph.microsoft.com/beta/me/messages/{message-id}/attachments/{arrachement-id}