Hello experts,
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. 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.