I am using Microsoft Graph. When I use
GET /me/messages/{messageId}/attachments
If there is an attachment shared through OneDrive or SharePoint, the @odata.type
will be #microsoft.graph.referenceAttachment
. And the size is very small because it is not real file.
{
"@odata.type": "#microsoft.graph.referenceAttachment",
"id": "AAMkADBlZTUwNTkxLWVmODgtNDVhNC1iZjhlLTdjNjA1ODZlMDI5MgBGAAAAAACUbnk-iwQZRbXMgkfKtmYhBwCpTc-InBsuTYwTUBb_VIb4AAAAAAEMAACpTc-InBsuTYwTUBb_VIb4AAEBiQutAAABEgAQAMqgyfrokPFCrRfUa2mrxxM=",
"name": "word.docx",
"contentType": null,
"size": 4601,
"isInline": false
}
Is there any way to get the actual url of this attachment that can be opened in the browser? Thanks
The v1.0 edition has very limited support for referenceAttachment
. And by that I mean, there isn't much you can do with them beyond acknowledging one exists.
The beta edition however supports a much richer referenceAttachment
object. When I come across a referenceAttachment
, I make the call to retrieve the attachment using the beta endpoint which does have links to the actual file:
{
"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"
}