根据
this link
目前可以通过Graph API更新用户邮箱设置。链接中的示例显示了如何通过C#更新自动回复,并指定了许多可以更新的其他字段,包括时区。
我正在使用
Microsoft.Graph 3.5.0
但是,当我尝试运行此代码时:
public async Task ResetMailboxTimezone(string id)
{
// id is a string version of a valid Guid with hyphens
const string defaultTimezone = "AUS Eastern Standard Time";
var newUser = new User();
var mbs = new MailboxSettings
{
AdditionalData = new Dictionary<string, object>
{
{"@odata.context", $"https://graph.microsoft.com/v1.0/$metadata#users('{id}')/mailboxSettings"}
},
TimeZone = defaultTimezone
};
newUser.MailboxSettings = mbs;
await _graphServiceClient.Users[azureGuid].Request().UpdateAsync(userChanges);
}
我有个例外:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: UpdateMailboxTimezone
---> Status Code: MethodNotAllowed
Microsoft.Graph.ServiceException: Code: ErrorInvalidRequest
Message: The OData request is not supported.
Inner error:
AdditionalData:
request-id: 246cb7f8-9f33-462c-82f1-3e41fd349053
date: 2020-05-18T10:12:51
ClientRequestId: 246cb7f8-9f33-462c-82f1-3e41fd349053
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)