I am attempting to pull message attachments from Outlook using the Graph API in order to add them to work items in DevOps. This is easy with most attachment types (.jpg, .txt, etc.) because I can jsut make a call using the attachment's ID and that returns a JSON response including the attachment's contentBytes property. This isn't the case with Outlook Item (.msg) attachments though; when I make the call to retrieve one the response doesn't include the .msg contentBytes property and the contentType is null, though it includes a size. This is the call I'm making:
https://graph.microsoft.com/v1.0/me/mailfolders/AAMkADQ3MjYwZDViLTRlNzAtNDA1Ny04Zjc4LTUwYmM2Nzg2M2EyMAAuAAAAAAAfmvj9nlKwQplPl8PwU0KdsfdgfQBGOwCVHaiaRqlanlgEYx7vAAADnEUzAAA=/messages/AAMkADQ3MjYwZDViLTRlNzAtNDA1Ny04Zjc4LTUwYmM2Nzg2M2EyMABGAAAAAAAfmvj9nlKwQpldfgdgd8PwU0KbBwBGOwCVHaiaRqlanlgEYx7vAAADnEUzAABGOwCVHaiaRqlanlgEYx7vAAADnFF0AAA=/attachments/AAMkADQ3MjYwZDViLTRlNzAtNDA1Ny04Zjc4LTUwYmM2Nzg2M2EyMABGAAAAAAAfmvj9nlKwQplPl8PwU0KbBwBGOwCVHaiaRqlanlgEYx7vAAADnEUzAABGOwCVHadfgdfgRqlanlgEYx7vAAADnFF0AAABEgAQAI1OgY3EDyJOvJn5C5Y4EL4=?$expand=microsoft.graph.itemattachment/item
And this is what is a sample of what is returned:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('487bb9c6-7816-4004-8ed2-1b533de057fb')/mailFolders('AAMkADQ3MjYwZDViLTRlNzAtNDA1Ny04Zjc4LTUwYmM2Nzg2M2EyMAAuAAAAAAAfmvj9nlKwQplPl8PwU0KbAQBGOwCVHaiaRqlanlgEYx7vAAADnEUzAAA%3D')/messages('AAMkADQ3MjYwZDViLTRlNzAtNDA1Ny04Zjc4LTUwYmM2Nzg2M2EyMABGAAAAAAAfmvj9nlKwQplPl8PwU0KbdgdgVHaiaRqlanlgEYx7vAAADnEUzAABGOwCVHaiaRqlanlgEYx7vAAADnFF0AAA%3D')/attachments(microsoft.graph.itemAttachment/item())/$entity",
"@odata.type": "#microsoft.graph.itemAttachment",
"id": "AAMkADQ3MjYwZDViLTRlNzAtNDA1Ny04dfgdgLTUwYmM2Nzg2M2EyMABGAAAAAAAfmvj9nlKwQplPl8PwU0KbBwBGOwCVHaiaRqlanlgEYx7vAAADnEUzAABGOwCVHaiaRqlanlgEYx7vAAADnFF0AAABEgAQAI1OgY3EDyJOvJn5C5Y4EL4=",
"lastModifiedDateTime": "2021-01-20T14:46:45Z",
"name": "RE: [EXTERNAL] RE: 10262 LabelWatcher 360, Aurora - Inpection Evaluation SR251470",
"contentType": null,
"size": 556542,
"isInline": false,
"[email protected]": "https://graph.microsoft.com/v1.0/$metadata#users('487bb9c6-7816-4004-8ed2-1b533de057fb')/mailFolders('AAMkADQ3MjYwZDViLTRlNzAtNDA1Ny04Zjc4LTUwYmM2Nzg2M2EyMAAuAAAAAAAfmvj9nlKwQplPl8PwU0KbAQBGOwCVHaiaRqlanlgEYx7vAAADnEUzAAA%3D')/messages('AAMkADQ3MjYwZDViLTRlNzAtNDA1Ny04Zjc4LTUwYmM2Nzg2M2EyMABGAAAAAAAfmvj9nlKwQplPl8PwU0KbBwBGOdgfgiaRqlanlgEYx7vAAADnEUzAABGOwCVHaiaRqlanlgEYx7vAAADnFF0AAA%3D')/attachments('AAMkADQ3MjYwZDViLTRlNzAtNDA1Ny04Zjc4LTUwYmM2Nzg2M2EyMABGAAAAAAAfmvj9nlKwQplPl8PwU0KbBwBGOwCVHaiaRqlanlgEYx7vAAADnEUzAABGOwCVHaiaRqlanlgEYx7vAAADnFF0AAABEgAQAI1OgY3EDyJOvJn5C5Y4EL4%3D')/microsoft.graph.itemAttachment/microsoft.graph.itemAttachment/item/$entity",
"item": {
"@odata.type": "#microsoft.graph.message",
"id": "",
"createdDateTime": "2021-01-20T14:46:51Z",
"lastModifiedDateTime": "2021-01-20T14:46:14Z",
"receivedDateTime": "2021-01-20T14:34:18Z",
"sentDateTime": "2021-01-20T14:34:05Z",
"hasAttachments": false,
"internetMessageId": "<[email protected]>",
"subject": "RE: [EXTERNAL] RE: 10262 LabelWatcher 360, Pretium Aurora - Inpection Evaluation SR251470",
"bodyPreview": "Hi Janay,\r\n\r\nGood morning. Wanted to see if you had an IT person available to check on the ethernet connection on the PC of this system?\r\n\r\nAn software programmer needs to connect to the system from our Headquarters.\r\n\r\nWe were successful in connecting to",
"importance": "normal",
"conversationId": "AAQkADQ3MjYwZDViLTRlNzdfgdgNy04Zjc4LTUwYmM2Nzg2M2EyMAAQAC78UtOzUEhpuj4wq5Ng7Js=",
"conversationIndex": "AdbT3F82LvxS07NQSGm6PjCrk2DsmwOzi3XQAAFX0/AAAEpZIAAACV3wADC/lIAAALGPmQAAJp7gAAEFqhAAAHx8oAAD7OwwAABtgdAAWirP4AAAB3MgABEkMsAAAPBt0AAAK8zAACYPXsACMO1hoAAnKxig",
"isReadReceiptRequested": false,
"isRead": true,
"isDraft": false,
"webLink": "https://outlook.office365.com/owa/?AttachmentItemID=AAMkADQ3MjYwZDViLTRlNzdgdg1Ny04Zjc4LTUwYmM2Nzg2M2EyMABGAAAAAAAfmvj9nlKwQplPl8PwU0KbBwBGOwCVHaiaRqlanlgEYx7vAAADnEUzAABGOwCVHaiaRqlanlgdhfghkjDnFF0AAABEgAQAI1OgY3EDyJOvJn5C5Y4EL4%3D&exvsurl=1&viewmodel=ItemAttachment"
}
}
Is there a way to retrieve this attachment's contentBytes? If not, should I maybe just add a comment to the work item that includes the .msg's weblink?
Thanks!