代码:
var stream=await this.oneDriveClient.Drive.Items[itemid].Content.Request().GetAsync();
一直运行好几周,但昨晚Onedrive更新后停止了工作。 它抛出异常' Microsoft.Graph.ServiceException'当我们尝试使用API下载文件时,文件上传仍然有效。我们也得到了" ItemNotFound"错误代码。
以下是异常消息和堆栈跟踪。
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
答案 0 :(得分:1)
问题出在身份验证上。这段代码似乎解决了这个问题:
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;
}
答案 1 :(得分:0)
我遇到了完全相同的问题。当检查Fiddler时,似乎返回的响应是一个带有消息的网页:&#34;抱歉出错了。抱歉,您无法访问此文档。 ...相关ID:072abf9d-7097-3000-a357-3f21c379dac7 ...&#34; Microsoft.Graph.ServiceException有一个错误代码:ItemNotFound。
这种情况已经存在了很长时间,现在突然停止了工作。
答案 2 :(得分:0)
这是OneDrive for Business服务中的一个问题,此问题已得到解决。对于给您带来的不便,我们深表歉意,并已采取措施尽量减少未来类似失败的可能性。