c# - 如果存在 Sharepoint,则创建文件夹
问题描述
我有以下代码,直到最近才运行良好
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:
知道发生了什么吗?没有代码推送导致这种情况。
解决方案
推荐阅读
- amazon-dynamodb - DynamoDB 扫描忽略大写或小写字母
- oauth-2.0 - OAuth2 服务注册表缓存未在 CAS 6.3.x 中补水
- python - 读取 CSV 时使用多个引号字符
- javascript - 如何替换字符串中的肤色变体表情符号?
- phpstorm - 如何使用 Xdebug 让 PhpStorm 忽略来自某个域的传入连接
- git - 如何强制 git 检测更改的文件(由于工作树编码)?
- javascript - 更改悬停以单击 Themify - 产品过滤器中的功能
- python-3.x - 对 xyz 数据点进行三角剖分
- c++ - 为什么不`std::set
::end()` 比较等于 `std::set ::迭代器{}`? - javascript - 我收到一个未捕获的类型错误:无法将属性“onclick”设置为 null