We're using MS Graph API to get the list of emails from an Outlook 365 mailbox. We have a requirement to list the attachments in every email.
When using the List Attachments endpoint of the Graph API, the contentBytes
attribute value in the response contains the entire Base64 encoded attachment content. This increases the response size significantly. We have no need to access or store the attachment content.
Is there a way in MS Graph API to just get the attachment file name(s) and IDs for one or more email messages?
Yes, you can use the same /attachments
endpoint and get only the id and name of attachment using the $select query parameter.
Simply use the query
https://graph.microsoft.com/v1.0/me/messages/{messageid}/attachments?$select=id,name
Result:
You can always test graph calls in Graph Explore.