MSGraph List Attachments API call returns all inline attachments regardless of message ID

Wesley Falcao 1 Reputation point
2022-03-17T20:31:27.263+00:00

I am using the GET /users/{id | userPrincipalName}/messages/{id}/attachments mentioned here - https://learn.microsoft.com/en-us/graph/api/message-list-attachments?view=graph-rest-1.0&tabs=http

But with this API call, I have observed that all inline attachments for the current email thread are returned, regardless of whether they were attached to the current message.

This is a sample log of my application showing the attachments retrieved for each message.

2022-03-17 20:11:25.405 DEBUG 9661 --- [geMailService-0] n.i.a.g.c.e.a.i.m.impl.MsGraphApiImpl    : Received attachments for message ID AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0AYwBZg9EnKUaPqnnD4hVqYgAAIMd88wAA. Attachments = [Attachment(contentType=image/jpeg, name=Car.jpg, size=32484), Attachment(contentType=application/pdf, name=SamplePDF1.pdf, size=3228), Attachment(contentType=application/msword, name=WordDoc1.doc, size=6854)]  
  
2022-03-17 20:16:33.911 DEBUG 9661 --- [geMailService-0] n.i.a.g.c.e.a.i.m.impl.MsGraphApiImpl    : Received attachments for message ID AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0AYwBZg9EnKUaPqnnD4hVqYgAAIMd9DgAA. Attachments = [Attachment(contentType=image/jpeg, name=Car.jpg, size=32484), Attachment(contentType=image/jpeg, name=AndroidIssue.jpg, size=59710), Attachment(contentType=application/msword, name=WordDoc2.doc, size=6854), Attachment(contentType=application/pdf, name=SamplePDF2.pdf, size=69599)]  
  
  
2022-03-17 20:19:53.366 DEBUG 9661 --- [geMailService-0] n.i.a.g.c.e.a.i.m.impl.MsGraphApiImpl    : Received attachments for message ID AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0AYwBZg9EnKUaPqnnD4hVqYgAAIMd9SgAA. Attachments = [Attachment(contentType=image/jpeg, name=Car.jpg, size=32484), Attachment(contentType=image/jpeg, name=AndroidIssue.jpg, size=59710), Attachment(contentType=image/png, name=WindowsCrash.png, size=285905), Attachment(contentType=application/pdf, name=SamplePDF3.pdf, size=13464), Attachment(contentType=application/msword, name=WordDoc3.doc, size=6854)]  
  
2022-03-17 20:23:42.547 DEBUG 9661 --- [geMailService-0] n.i.a.g.c.e.a.i.m.impl.MsGraphApiImpl    : Received attachments for message ID AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0AYwBZg9EnKUaPqnnD4hVqYgAAIMd9ZQAA. Attachments = [Attachment(contentType=image/jpeg, name=Car.jpg, size=32484), Attachment(contentType=image/jpeg, name=AndroidIssue.jpg, size=59710), Attachment(contentType=image/png, name=WindowsCrash.png, size=285905), Attachment(contentType=image/png, name=iPhoneIssue.png, size=622409), Attachment(contentType=application/msword, name=WordDoc4.doc, size=6854), Attachment(contentType=application/pdf, name=SamplePDF4.pdf, size=8145)]  

In the above log you can see that in each email message I have uploaded a word document, a PDF, and an inline image.

The API call correctly returns the word doc and the PDF associated with each message, but it returns ALL inline messages in the email thread up to that point.

Is this an issue with the API or am I missing something?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,836 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Wesley Falcao 1 Reputation point
    2022-03-18T14:54:38.097+00:00

    If by client ID you mean the tenant ID then that is 13e8af8d-a69b-4fb8-b6d3-102ee6fb2c31.

    I do not know the request IDs for the above, so I created new requests and logged the received response headers. You can see the request ID in them. The timestamps are in the log entries below. They are in UTC. The scenario is the same as above. For each email, send an inline image, a PDF, and a word document.

    2022-03-18 14:33:42.958 DEBUG 4143 --- [geMailService-0] n.i.a.g.c.e.a.i.m.impl.MsGraphApiImpl : Response headers
    [Cache-Control:"private", Transfer-Encoding:"chunked", Content-Type:"application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8", Vary:"Accept-Encoding", Strict-Transport-Security:"max-age=31536000", request-id:"0e262ae6-c2df-4702-bf9e-5222744dbc76", client-request-id:"0e262ae6-c2df-4702-bf9e-5222744dbc76", x-ms-ags-diagnostic:"{"ServerInfo":{"DataCenter":"East US","Slice":"E","Ring":"5","ScaleUnit":"003","RoleInstance":"BL6PEPF0000F2F5"}}", Preference-Applied:"IdType=ImmutableId", Date:"Fri, 18 Mar 2022 14:33:43 GMT"]
    2022-03-18 14:33:42.958 DEBUG 4143 --- [geMailService-0] n.i.a.g.c.e.a.i.m.impl.MsGraphApiImpl : Received attachments for message ID AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0AYwBZg9EnKUaPqnnD4hVqYgAAIMfBrQAA. Attachments = [Attachment(contentType=image/jpeg, name=Image1.jpg, size=32502), Attachment(contentType=application/pdf, name=SamplePDF1.pdf, size=3228), Attachment(contentType=application/msword, name=WordDoc1.doc, size=6854)]

    2022-03-18 14:42:00.475 DEBUG 4143 --- [geMailService-0] n.i.a.g.c.e.a.i.m.impl.MsGraphApiImpl : Response headers
    [Cache-Control:"private", Transfer-Encoding:"chunked", Content-Type:"application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8", Vary:"Accept-Encoding", Strict-Transport-Security:"max-age=31536000", request-id:"105d433f-7912-46e9-b872-e3bc31fe470f", client-request-id:"105d433f-7912-46e9-b872-e3bc31fe470f", x-ms-ags-diagnostic:"{"ServerInfo":{"DataCenter":"North Central US","Slice":"E","Ring":"3","ScaleUnit":"002","RoleInstance":"CH01EPF00009C6A"}}", Preference-Applied:"IdType=ImmutableId", Date:"Fri, 18 Mar 2022 14:42:00 GMT"]
    2022-03-18 14:42:00.476 DEBUG 4143 --- [geMailService-0] n.i.a.g.c.e.a.i.m.impl.MsGraphApiImpl : Received attachments for message ID AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0AYwBZg9EnKUaPqnnD4hVqYgAAIMfFugAA. Attachments = [Attachment(contentType=image/jpeg, name=Image1.jpg, size=32502), Attachment(contentType=image/jpeg, name=Image2.jpg, size=59682), Attachment(contentType=application/pdf, name=SamplePDF2.pdf, size=69599), Attachment(contentType=application/msword, name=WordDoc2.doc, size=6854)]

    2022-03-18 14:45:31.267 DEBUG 4143 --- [geMailService-0] n.i.a.g.c.e.a.i.m.impl.MsGraphApiImpl : Response headers
    [Cache-Control:"private", Transfer-Encoding:"chunked", Content-Type:"application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8", Vary:"Accept-Encoding", Strict-Transport-Security:"max-age=31536000", request-id:"b0056c15-44c5-4123-b311-115ad6060014", client-request-id:"b0056c15-44c5-4123-b311-115ad6060014", x-ms-ags-diagnostic:"{"ServerInfo":{"DataCenter":"North Central US","Slice":"E","Ring":"3","ScaleUnit":"002","RoleInstance":"CH01EPF00009C6A"}}", Preference-Applied:"IdType=ImmutableId", Date:"Fri, 18 Mar 2022 14:45:30 GMT"]
    2022-03-18 14:45:31.268 DEBUG 4143 --- [geMailService-0] n.i.a.g.c.e.a.i.m.impl.MsGraphApiImpl : Received attachments for message ID AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0AYwBZg9EnKUaPqnnD4hVqYgAAIMfF7AAA. Attachments = [Attachment(contentType=image/jpeg, name=Image1.jpg, size=32502), Attachment(contentType=image/jpeg, name=Image2.jpg, size=59682), Attachment(contentType=image/png, name=Image3.png, size=622385), Attachment(contentType=application/pdf, name=SamplePDF3.pdf, size=13464), Attachment(contentType=application/msword, name=WordDoc3.doc, size=6854)]

    2022-03-18 14:49:34.510 DEBUG 4143 --- [geMailService-0] n.i.a.g.c.e.a.i.m.impl.MsGraphApiImpl : Response headers
    [Cache-Control:"private", Transfer-Encoding:"chunked", Content-Type:"application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8", Strict-Transport-Security:"max-age=31536000", request-id:"ed10c479-e2ea-47b0-8043-a22c9f831d30", client-request-id:"ed10c479-e2ea-47b0-8043-a22c9f831d30", x-ms-ags-diagnostic:"{"ServerInfo":{"DataCenter":"North Central US","Slice":"E","Ring":"3","ScaleUnit":"000","RoleInstance":"CH01EPF00007835"}}", Preference-Applied:"IdType=ImmutableId", Date:"Fri, 18 Mar 2022 14:49:34 GMT"]
    2022-03-18 14:49:34.510 DEBUG 4143 --- [geMailService-0] n.i.a.g.c.e.a.i.m.impl.MsGraphApiImpl : Received attachments for message ID AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0AYwBZg9EnKUaPqnnD4hVqYgAAIMfGCQAA. Attachments = [Attachment(contentType=image/jpeg, name=Image1.jpg, size=32502), Attachment(contentType=image/jpeg, name=Image2.jpg, size=59682), Attachment(contentType=image/png, name=Image3.png, size=622385), Attachment(contentType=image/png, name=Image4.png, size=285877), Attachment(contentType=application/pdf, name=SamplePDF4.pdf, size=8145), Attachment(contentType=application/msword, name=WordDoc4.doc, size=6854)]

    0 comments No comments