AddAsync(driveItem)不返回 [英] AddAsync(driveItem) does not return

查看:126
本文介绍了AddAsync(driveItem)不返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码中的.AddAsync(driveItem)永不返回.有人能对此有所启发吗?

The .AddAsync(driveItem) in the following code never returns. Could anyone shed some light on this?

IPublicClientApplication publicClientApplication = PublicClientApplicationBuilder
    .Create(App.ClientId)
    .Build();

DeviceCodeProvider authProvider = new DeviceCodeProvider(
    publicClientApplication,
    new string[] { "Files.ReadWrite.All" });

GraphServiceClient graphClient = new GraphServiceClient(authProvider);
DriveItem driveItem = new DriveItem
{
    Name = "Foo",
    Folder = new Folder { },
    AdditionalData = new Dictionary<string, object>()
    { { "@microsoft.graph.conflictBehavior", "fail" }
    }
};
await graphClient
    .Me
    .Drive
    .Root
    .Children
    .Request()
    .AddAsync(driveItem);

我尝试使用除"Foo"以外的其他文件夹名称,尝试使用现有或不存在的文件夹的名称都无济于事.

I have tried folder names other than "Foo", tried names of existing or non-existing folders to no avail.

我也尝试为"@ microsoft.graph.conflictBehavior"使用重命名"而不是失败".

I also tried "rename" instead of "fail" for "@microsoft.graph.conflictBehavior" to no avail.

我也尝试了没有AdditionalData的尝试.
我决定等待该方法返回一段时间(超过10分钟),它最终引发了异常:

I also tried without AdditionalData to no avail.
I decided to wait for the method to return for a while (more than 10 minutes), and it finally threw an exception:

代码:generalException消息:发送请求时发生错误.

Code: generalException Message: An error occurred sending the request.

来源"Microsoft.Graph.Core"

Source "Microsoft.Graph.Core"

  at Microsoft.Graph.HttpProvider.<SendRequestAsync>d__19.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Graph.HttpProvider.<SendAsync>d__18.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Graph.BaseRequest.<SendRequestAsync>d__35.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Graph.BaseRequest.<SendAsync>d__31`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()

内部异常:

代码:generalException消息:发生意外异常 验证请求.

Code: generalException Message: Unexpected exception occured while authenticating the request.

   at Microsoft.Graph.Auth.DeviceCodeProvider.<GetNewAccessTokenAsync>d__14.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Graph.Auth.DeviceCodeProvider.<AuthenticateRequestAsync>d__13.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Graph.AuthenticationHandler.<SendAsync>d__16.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Net.Http.HttpClient.<FinishSendAsyncBuffered>d__62.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Graph.HttpProvider.<SendRequestAsync>d__19.MoveNext()

以下代码具有完全相同的问题:

The following code has exactly the same problem:

IDriveItemChildrenCollectionPage children = await graphClient.Me.Drive.Root.Children
    .Request()
    .GetAsync();

这似乎是Graph SDK的普遍问题.

This looks like a general problem for the Graph SDK.

我进行了Azure Active Directory的应用注册,并获得了以下最内部的异常:

I played the app registration of Azure Active Directory, and got the following most inner exception:

AADSTS70000: The provided value for the input parameter 'device_code' is not valid.
Trace ID: 7067d5e9-d811-49ed-9b8b-7a0b9a0c4c00
Correlation ID: a4faa514-debc-47dc-8ef3-0b9853949e28
Timestamp: 2020-01-11 06:47:36Z

同样,我必须等待10分钟以上才能引发异常.

Again, I have to wait for more than 10 minutes for the exception to be thrown.

不知道为什么使用 Microsoft.Toolkit.Graph.Controls 完全相同的调用可以正常工作.

Not sure why exactly the same calls using Microsoft.Toolkit.Graph.Controls work perfectly.

await provider.Graph.Me.Drive.Root.Children
.Request()
.AddAsync(driveItem);

推荐答案

我不确定为什么不返回,但是Camera Roll

I'm not sure why this isn't returning, but Camera Roll is one of the special folders (and therefore a reserved folder name). There are a small number of these that get automatically generated either when the Drive is provisioned or when a specific service connects for the first time (i.e. "Camera Roll" is created by the OneDrive app):

  • 文档
  • 照片
  • 胶卷
  • 应用程序根
  • 音乐

要检索相机胶卷"文件夹,请通过其"id"进行请求:

In order to retrieve the Camera Roll folder, you request it by it's "id":

GET /me/drive/special/cameraroll

这篇关于AddAsync(driveItem)不返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆