Using MS Graph SDK or MS graph explorer, we are trying to replace an attachment within a message. Updating a message attachment is not supported yet by ms graph API (or at least that's what we know). that's why we do the operation in the following steps:
get the original attachment content.
modify that content.
delete the original attachment.
then add the modified content as a new attachment with the same name.
This works. However, randomly fails, resulting in two attachments, the original and the new instead of the message having one updated attachment. the API returns success results in both cases with no indication of what might be the problem.
Here are the calls:
First Request to delete the attachment (step 3):
DELETE https://graph.microsoft.com/v1.0/me/messages/{messageId}/attachments/{attachmentId}
Second Request to add the modified attachment (step 4):
POST https://graph.microsoft.com/v1.0/me/messages/{messageId}/attachments
body:
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "smime.p7m",
"contentType": "application/x-pkcs7-mime",
"contentBytes": "{contentBytes}"
}
Any feedback on what might be causing the issue would be appreciated.
After some research on this, it looks like this is not an issue with ms graph. The thing is that we are using outlook for mobile on IOS to check the message after being manipulated and the outlook app does not update the attachment correctly which results in two attachments being displayed. If we query the message using ms graph explorer we can see that the attachment was replaced correctly. We concluded that this is a bug in Outlook app o IOS.
To confirm, we reinstalled the outlook app on IOS and the message with its attachments was displayed correctly.