如果存在,则创建文件夹 Sharepoint

时间:2021-03-08 12:21:42

标签: c# sharepoint microsoft-graph-api

我有以下代码直到最近都运行良好

private async Task<DriveItem> CreateFolderIfNotExists(GraphServiceClient graphClient, string driveId, string folderName)
    {
        try
        {
            var driveItem = new DriveItem
            {
                Name = folderName,
                Folder = new Folder(),
                AdditionalData = new Dictionary<string, object>()
                {
                    { "@microsoft.graph.conflictBehavior", "fail" }
                }
            };

            return await graphClient.Drives[driveId].Root.Children
                .Request()
                .AddAsync(driveItem);
        }
        catch (ServiceException exception)
        {
            if (exception.StatusCode != HttpStatusCode.Conflict)
            {
                throw;
            }

            return await this.GetFolderItem(graphClient, driveId, folderName);
        }
    }

突然间我们得到了这个:

<块引用>

System.NullReferenceException:未将对象引用设置为对象的实例。在 Microsoft.Graph.HttpProvider.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancelationToken) 在 Microsoft.Graph.BaseRequest.SendRequestAsync(Object serializableObject, CancellationToken cancelationToken, HttpCompletionOption completionOption) 在 Microsoft.Graph.BaseRequest.SendAsync[T](Object serializableObject , CancellationToken CancellationToken, HttpCompletionOption completionOption) at xyz.CreateFolderIfNotExists(GraphServiceClient graphClient, String driveId, String folderName) in xyz\Client\SharePointClient.cs:line 63 at xyz.Client.SharePointClient.CopyLegacyFile(String fileId, String destination, String newFileName, String documentLibraryId) xyz\Client\SharePointClient.cs:line 222 at xyz.SharePointDocumentStorage.New() in xtz\SharePointDocumentStorage.cs:line 56 at zzzWorkflowAppService.NewRevision(NewRevisionInput input) at Abp.Authorization.AuthorizationInterceptor.InternalInterceptAsynchronous[T Result](IInvocation invocation) at Abp.Domain.Uow.UnitOfWorkInterceptor.InternalInterceptAsynchronous[TResult](IInvocation invocation) at Abp.EntityHistory.EntityHistoryInterceptor.InternalInterceptAsynchronous[TResult](IInvocation invocation) at Abp.Auditing.AuditingInterceptor.InternalResultInterceptor[TResult](IInvocation invocation) IInvocation 调用)在 Abp.Runtime.Validation.Interception.ValidationInterceptor.InternalInterceptAsynchronou...

知道发生了什么吗?没有代码推送导致这种情况。

0 个答案:

没有答案