0
votes

I am new to Microsoft Graph API. The requirement on our application is to collect the latest email based on expected subject and collect the attachment of the email (CSV format).

This is working fine already when using the queries below but using 2 GET requests:

First is for collecting the latest email:

https://graph.microsoft.com/v1.0/me/messages?$select=id,hasAttachments&$top=1&$filter=subject eq '{subject}'

Second is for collecting the attachment by passing the id returned from the first query:

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

Question: Is there a way to just merge this request into one to make the code even better?

Thank you!

2

2 Answers

0
votes

To my current knowledge, there isn't a way to merge these two requests. As you have pointed out, the message id is required to list attachments.

0
votes

Update: I was able to merge two requests with the user of $expand parameter:

https://graph.microsoft.com/v1.0/me/messages?$select=id,hasAttachments&$top=1&$filter=subject eq '{subject}'&$expand=attachments