microsoftgraph / msgraph-sdk-serviceissues

Tracks service issues for follow up.
5 stars 0 forks source link

Error 400 while trying to access a shared drive item content #59

Open jcze91 opened 3 years ago

jcze91 commented 3 years ago

Describe the bug Hello, I'm trying to access a shared drive item via Microsoft Graph API by using the C# SDK. It's ok sometimes, but randomly it's failing on 400 error.

To Reproduce Here is my code : var graphClient = new GraphServiceClient(CreateAuthProvider()); var token = $"u!{Convert.ToBase64String(Encoding.UTF8.GetBytes(url)).TrimEnd('=').Replace('/', '_').Replace('+', '-')}"; var content = await graphClient.Shares[token].DriveItem.Content.Request(new List<Option> { new HeaderOption("Prefer", "redeemSharingLink") }).GetAsync();

I get this error 400 sometimes : ` Code: UnknownError Message: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">

Bad Request

Bad Request - Invalid URL


HTTP Error 400. The request URL is invalid.

Inner error:
    AdditionalData:
    date: 2021-03-31T10:42:07
    request-id: dd8f728a-9b0c-44e2-bdb1-40377f7e8017
    client-request-id: dd8f728a-9b0c-44e2-bdb1-40377f7e8017
ClientRequestId: dd8f728a-9b0c-44e2-bdb1-40377f7e8017

`

Expected behavior Obtaining the drive item content

Desktop (please complete the following information):

Additional context I'm using the SDK C# version 3.28.0.

AB#8812

MIchaelMainer commented 3 years ago

Do you retry on that 400 status code and if so, does it successfully return? Does this error occur when trying to access the same item?

jcze91 commented 3 years ago

No, there isn't retry on 400 error and we're not trying to access the same item. For additional context, we try to fetch multiple drive items (10 to 20) consecutively, and each time we time to reproduce it, the 400 error is on a different item. I'll try to fetch them via one batch Graph API call

jcze91 commented 3 years ago

When trying with batch API call, I still have some request ending in 400 error Bad Request, so I suppose it's not a concurrency problem.

I could found a workaround by using a retry policy on the call, but it's not a very suitable patch. var graphClient = new GraphServiceClient(CreateAuthProvider()); var token = $"u!{Convert.ToBase64String(Encoding.UTF8.GetBytes(url)).TrimEnd('=').Replace('/', '_').Replace('+', '-')}"; var content = await Policy.Handle<ServiceException>(ex => ex.StatusCode == HttpStatusCode.BadRequest) .Or<HttpRequestException>() .WaitAndRetryAsync(7, retryCount => TimeSpan.FromSeconds(Math.Pow(2, retryCount) / 2)) .ExecuteAsync<Stream>(() => graphClient.Shares[token].DriveItem.Content.Request().GetAsync());

For information, this bug looks to have occurred only in the last few days, since the 30th March on our side.

MIchaelMainer commented 3 years ago

@JeremyKelley can you comment on any changes in the service API that may cause intermittent errors when using shared files API?

petrhollayms commented 2 months ago

Thank you for reporting this issue. This appears to be an issue or limitation with the service APIs. Unfortunately, as the Microsoft Graph SDK team, we do not have ownership of the APIs that are causing you issues. We invite you to create a question about the service API to Microsoft Q&A and tagged with one of the [microsoft-graph-*] tags, that way it will get routed to the appropriate team for them to triage:

https://aka.ms/msgraphsupport or directly https://aka.ms/askgraph

For now, we will close the issue on our side but feel free to open it in the relevant repository if you think the issue is specific to SDK. Please let us know if this helps!

Note: We will close this repository on April 19, 2024.