Reputation: 11
The code:
var stream=await this.oneDriveClient.Drive.Items[itemid].Content.Request().GetAsync();
Has been running fine for weeks but stopped working after the Onedrive update last night. It is throwing exception 'Microsoft.Graph.ServiceException' when we try to download files using the API, file uploads still work. We are also getting the "ItemNotFound" error code.
Below is the exception message and stack trace.
ex.Message: Exception of type 'Microsoft.Graph.ServiceException' was thrown.
ex.StackTrace:
at Microsoft.Graph.HttpProvider.<SendAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Graph.BaseRequest.<SendRequestAsync>d__34.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Graph.BaseRequest.<SendStreamRequestAsync>d__33.MoveNext()
-- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at TMSPro.Shared_Objects.ucOneDriveBrowser.<btnDownload_Click>d__5f.MoveNext() in c:\Working\TMSPro_VS2012\TMSPro\Shared_Objects\ucOneDriveBrowser.cs:line 1083
Upvotes: 0
Views: 360
Reputation: 4192
This was an issue in the OneDrive for Business service that has since been resolved. We apologize for the inconvenience, and have taken steps to minimize the chances of similar failures in the future.
Upvotes: 0
Reputation: 11
The issue is with Authentication. This code seems to fix it:
var adalAuthProvider = new AdalAuthenticationProvider(
this.AadClientId,
this.AadReturnUrl);
this.oneDriveClient = new OneDriveClient(this.AadTargetUrl + "/_api/v2.0", adalAuthProvider, new HttpProvider(new HttpClientHandler { AllowAutoRedirect = true }, true));
authTask = adalAuthProvider.AuthenticateUserAsync(this.AadTargetUrl);
try
{
await authTask;
}
Upvotes: 1
Reputation: 71
I'm experiencing exactly the same issue. When checking Fiddler, it seems that the response that is returned is a web page with the message: "Sorry something went wrong. Sorry you cannot access this document. ... Correlation ID: 072abf9d-7097-3000-a357-3f21c379dac7 ..." The Microsoft.Graph.ServiceException has an error code: ItemNotFound.
This was working for ages, and now suddenly stopped working.
Upvotes: 0