-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Downloading Attachment requires delay #2207
Comments
Thanks for raising this @grippstick From the error description it looks like the API would occasionally need sometime before the attachment is available for download. As this is an API related issue, and this repo is mainly intended for issues related to the SDK, any chance you can create a ticket/question at the link below to get feedback from the API owners if this is expected from the API and whether there is an expected timeout before making the subsequent request? |
I have asked the question on the suggested site.
With that said, I would think the SDK may want to document or implement
some sort of fail safe in this scenario.
…On Tue, Nov 14, 2023 at 1:35 AM Eastman ***@***.***> wrote:
Thanks for raising this @grippstick <https://github.com/grippstick>
From the error description it looks like the API would occasionally need
sometime before the attachment is available for download. As this is an API
related issue, and this repo is mainly intended for issues related to the
SDK, any chance you can create a ticket/question at the link below to get
feedback from the API owners if this is expected from the API and whether
there is an expected timeout before making the subsequent request?
https://developer.microsoft.com/en-us/graph/support
—
Reply to this email directly, view it on GitHub
<#2207 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABBPTOTEMSJIM4KTAUD6VUDYEMNNHAVCNFSM6AAAAAA7GNIGQKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBZGY3TQNJZGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Joshua
|
Thanks for confirming @grippstick The SDK by default does implement retry mechanisms based on the API guidance at https://learn.microsoft.com/en-us/graph/best-practices-concept#handling-expected-errors for 502,503 and 429 errors. Unfortunately, for a 404 error, it gets tricky to really know if the item does not really exist or hasn't been provisioned yet as in your scenario. One thing you could do though is pass custom retry options to the retry handler for the request so that is caters for 404 response. var attMS = await graphClient.Me
.Messages["massage-id"]
.Attachments["attachement-id"]
.Request()
.WithShouldRetry((delay, attempt, response) =>
{
if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
return true; // retry for 404 for this request.
return false;
})
.WithMaxRetry(3)// max retry of 3
.GetAsync()
.ConfigureAwait(false) as FileAttachment; |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. |
After receiving a Subscription notification that an Email has been created. I check to see if the email has attachments. If it does, I attempt to download the attachments.
I will initially get the following exception:
Exception Type: Microsoft.Graph.ServiceException
Error: Code: ErrorItemNotFound
Message: The specified object was not found in the store., The store ID provided isn't an ID of an item.
If I repeatedly retry to download the attachments, it will eventually succeed after 4-5 minutes.
To Reproduce
var msg = await graphClient.Me.Messages[MicrosoftId]
.Request()
.WithImmutableId()
.Expand(EXPAND_MIME_HEADERS) .Select("internetMessageId,internetMessageHeaders,createdDateTime,subject,bodyPreview,hasAttachments,uniqueBody,body,from,toRecipients,ccRecipients,bccRecipients,isDraft")
.GetAsync()
.ConfigureAwait(false);
var atts = await graphClient.Me.Messages[MicrosoftId].Attachments
.Request()
.WithImmutableId()
.Select("id,name,size,isInline,contentType,microsoft.graph.fileAttachment/contentId")
.GetAsync(cancelAttachments.Token)
.ConfigureAwait(false);
foreach(var att in atts){
//Fails with above error
//failure is intermittent
var attMS = await graphClient.Me
.Messages[msg.Id]
.Attachments[att.Id]
.Request()
.WithImmutableId()
.GetAsync()
.ConfigureAwait(false) as FileAttachment;
}
I expect attachments to download.......
The text was updated successfully, but these errors were encountered: