【问题标题】:Create folder if exists Sharepoint suddenly stopped working如果存在则创建文件夹 Sharepoint 突然停止工作
【发布时间】:2021-03-08 12:36:46
【问题描述】:

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

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 cancelToken) 在 Microsoft.Graph.BaseRequest.SendRequestAsync(Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption) 在 Microsoft.Graph.BaseRequest.SendAsync[T](Object serializableObject ,xyz\Client\SharePointClient.cs 中 xyz.CreateFolderIfNotExists(GraphServiceClient graphClient, String driveId, String folderName) 处的 CancellationTokencancellationToken, HttpCompletionOption completionOption):xyz.Client.SharePointClient.CopyLegacyFile (String fileId, String destination, String newFileName) 处的第 63 行字符串 documentLibraryId) xyz\Client\SharePointClient.cs:xyz.SharePointDocumentStorage.New() 中 xtz\SharePointDocumentStorage.cs 中的第 222 行:zzzWorkflowAppService.NewRevision(NewRevisionInput 输入) 中 Abp.Authorization.AuthorizationInterceptor.InternalInterceptAsynchronous[T] 中的第 56 行结果](IInvocation 调用)在 Abp.Domain.Uow.UnitOfWorkInterceptor.InternalInterceptAsynchronous[TResult](IInvocation 调用)在 Abp.EntityHistory.EntityHistoryInterceptor.InternalInterceptAsynchronous[TResult](IInvocation 调用)在 Abp.Auditing.AuditingInterceptor.InternalInterceptAsynchronous[TResult]( IInvocation 调用)在 Abp.Runtime.Validation.Interception.ValidationInterceptor.InternalInterceptAsynchronou...

知道发生了什么吗?没有代码推送导致此问题。

它不是What is a NullReferenceException, and how do I fix it?的重复项

【问题讨论】:

    标签: sharepoint microsoft-graph-api


    【解决方案1】:

    看来我的microsoft Graph 版本是1.21.0 版本需要升级。一定有一个由 MS 托管的重大更改。

    可能与这个问题https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/901

    有关

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-03
      • 2017-08-22
      • 2021-02-01
      • 2016-12-29
      • 2018-05-09
      • 2015-12-07
      相关资源
      最近更新 更多