Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

412 (Precondition Failed) when add attachments at same time

I am using Microsoft Graph. I try to add two attachments by

POST /me/messages/{messageId}/attachment

{
  "@odata.type": "#microsoft.graph.fileAttachment",
  "name": "1.txt",
  "contentBytes": "SGVsbG8gd29ybGQh"
}

POST /me/messages/{messageId}/attachment

{
  "@odata.type": "#microsoft.graph.fileAttachment",
  "name": "2.txt",
  "contentBytes": "SGVsbG8gd29ybGQhIQ=="
}

It gave me 412 (Precondition Failed) error when I add these two attachments at same time.

{
  "code": "ErrorIrresolvableConflict",
  "message": "The send or update operation could not be performed because the change key passed in the request does not match the current change key for the item., Cannot save changes made to an item to store.SaveStatus: IrresolvableConflict\r\nPropertyConflicts:\r\n",
  "innerError": {
    "request-id": "20e95141-5d2d-41e3-8eed-3bbd24bcf52a",
    "date": "2017-11-28T07:18:45"
  }
}
like image 460
Hongbo Miao Avatar asked Nov 28 '17 07:11

Hongbo Miao


1 Answers

Right now the walkaround way is delaying the second POST around 100 milliseconds. If less than 100 milliseconds, it will be more likely to fail. (The chance to fail might also be related with the size of attachment, I didn't do further test)

But if I have 10 attachments, between each two POSTs, there will be 100 milliseconds delay.

BTW, I saw this issue even exists in Outlook client, when people send mail, they got same error: check here. So it might be a server issue.

[Just move from my original question to answer]

like image 141
Hongbo Miao Avatar answered Sep 18 '22 17:09

Hongbo Miao