1
votes

I am using ms graph api to get all the messages with attachments. Over this I need to get the files having docx/pdf extensions. Below are the filters I have tried.

https://graph.microsoft.com/v1.0/me/messages?$filter=hasAttachments eq true and ext eq 'docx'

https://graph.microsoft.com/v1.0/me/messages?$filter=hasAttachments eq true and extensions eq 'docx'

1

1 Answers

2
votes

You'll need to do this using multiple API calls. First you need to retrieve a list of messages with attachments (has Attachments) and then you need to iterate over the resulting ids in order to retrieve the attachment metadata.

For example, the call returns a list of message ids that have attachments:

https://graph.microsoft.com/v1.0/me/messages?$filter=hasAttachments eq true&$select=id

For each of the IDs we got back, we then make a second call to get the attachments:

https://graph.microsoft.com/v1.0/me/messages/{message id}/attachments

From these results you can inspect the Attachment's name property to determine what the file extension is.