msgraph-sdk-dotnet
msgraph-sdk-dotnet copied to clipboard
Cannot upload large attachment by upload session simultaneously
Describe the bug I'm using Micosoft.Graph 4.11.0 to send email with attachment, but in recent days I always get below error when more than 2 files upload simultaneously. it is reproduced every time.
Status Code: PreconditionFailed\r\nMicrosoft.Graph.ServiceException: Code: ErrorIrresolvableConflict\r\nMessage: 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.\r\n\r\n at Microsoft.Graph.SimpleHttpProvider.<SendAsync>d__10.MoveNext()
To Reproduce Steps to reproduce the behavior: Code of mine private async Task attachFiles() { foreach (var largeFile in largeFiles) { tasks.Add(UploadLargeFile(message, largeFile)); } await Task.WhenAll(tasks); }
private async Task UploadLargeFile(Message message, CustomerFile largeFile, int index) {
var attachmentItem = new AttachmentItem
{
AttachmentType = AttachmentType.File,
Name = largeFile.Name,
Size = largeFile.Content.Length,
};
UploadSession uploadSession = await EmailGraphClient.Users[account].Messages[message.Id].Attachments
.CreateUploadSession(attachmentItem)
.Request().PostAsync();
using (System.IO.MemoryStream ms = new System.IO.MemoryStream(largeFile.Content))
{
var largeFileUpload = new LargeFileUploadTask<byte[]>(uploadSession, ms);
await largeFileUpload.UploadAsync();
}
}
Expected behavior No exception
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: windows 10
- .net framework 461
- Micosoft.Graph 4.11.0
Additional context Add any other context about the problem here.