图形 API 设置共享点联机权限失败



我们有一个系统,该系统使用后台服务来设置使用 .Net Graph SDK 对新创建的 SharePoint Online 文档的权限。 看似随机的,我们的操作失败并出现 UnknownError 响应,我们不确定从那里开始。

我们尝试按需重现该问题,但我们仅在非交互式后台服务上遇到该问题。 后台服务执行此操作的次数比我们尝试按需执行的次数要多得多,因此在这种情况下,此操作发生得更多是有道理的。

var driveRecipients = new List<DriveRecipient>();
// Code that adds recipients
// var recipient = new DriveRecipient { Email = "..." };
// driveRecipients.Add(recipient)
var roles = new List<string> { "write" };
var inviteResult = await graphClient
.Drives[driveId]
.Items[fileId]
.Invite(driveRecipients, true, roles, notifyUsers, "Automated SharePoint permission added by app X")
.Request().PostAsync(cancellationToken);
return inviteResult;

通常,我们会收到 IDriveItemInviteCollectionPage 结果,但是当发生错误时,会抛出类似于以下内容的异常(由于该服务是非交互式的,因此我们只能访问记录的序列化异常(:

Exception: {
Data: [
]
Error: {
AdditionalData: null
Code: UnknownError
InnerError: {
AdditionalData: {
date: 2019-09-06T19:08:23.0000000
request-id: 607a5beb-6742-45c7-893f-9352242c70d4
}
Code: null
InnerError: null
Message: null
ThrowSite: null
_typeTag: Error
}
Message:
ThrowSite: null
_typeTag: Error
}
HResult: -2146233088
HelpLink: null
InnerException: null
Message: Code: UnknownError
Inner error
ResponseHeaders: [
{
Key: Cache-Control
Value: [
private
]
_typeTag: KeyValuePair`2
}
{
Key: Transfer-Encoding
Value: [
chunked
]
_typeTag: KeyValuePair`2
}
{
Key: request-id
Value: [
607a5beb-6742-45c7-893f-9352242c70d4
]
_typeTag: KeyValuePair`2
}
{
Key: client-request-id
Value: [
607a5beb-6742-45c7-893f-9352242c70d4
]
_typeTag: KeyValuePair`2
}
{
Key: x-ms-ags-diagnostic
Value: [
{"ServerInfo":{"DataCenter":"West US 2","Slice":"SliceC","Ring":"4","ScaleUnit":"000","RoleInstance":"AGSFE_IN_3","ADSiteName":"WUS2"}}
]
_typeTag: KeyValuePair`2
}
{
Key: Duration
Value: [
10019.4936
]
_typeTag: KeyValuePair`2
}
{
Key: Strict-Transport-Security
Value: [
max-age=31536000
]
_typeTag: KeyValuePair`2
}
{
Key: Date
Value: [
Fri, 06 Sep 2019 19:08:22 GMT
]
_typeTag: KeyValuePair`2
}
]
Source: Microsoft.Graph.Core
StackTrace:    at Microsoft.Graph.HttpProvider.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at Microsoft.Graph.BaseRequest.SendRequestAsync(Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
at Microsoft.Graph.BaseRequest.SendAsync[T](Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
at Microsoft.Graph.DriveItemInviteRequest.PostAsync(CancellationToken cancellationToken)
at <...>
at <...>
StatusCode: GatewayTimeout
TargetSite: Void MoveNext()
_typeTag: ServiceException
}

感谢您提供诊断信息!您的客户端代码不是问题所在。这可能是暂时性服务器问题。

将 Microsoft Graph .NET 客户端库的版本升级到版本 1.17.0,因为我们引入了对 504 错误进行自动重试。您应该看到此问题已通过升级得到解决。如果您不这样做,请告诉我们。

最新更新