如何使用 Microsoft Graph API 更新 MailboxSettings

How can I Update the MailboxSettings with Microsoft Graph API(如何使用 Microsoft Graph API 更新 MailboxSettings)
本文介绍了如何使用 Microsoft Graph API 更新 MailboxSettings的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从不同的日历更新 MailboxSettings.

I want to update the MailboxSettings from different calendar.

如何构建可以通过 Microsoft Graph 更新 MailboxSetting 的请求?

How Can I build the Request that I can update the MailboxSetting via Microsoft Graph?

这是我的代码示例,但有例外:

Here is my code example with the exception:

代码示例:

User obj = GraphServiceClient.Users[roomCalendarId].Request().Select("MailboxSettings").GetAsync().Result;
WorkingHours mailboxSettingsWorkingHours = obj.MailboxSettings.WorkingHours;

TimeOfDay tOd = new TimeOfDay(start.Hour, start.Minute, start.Second);
mailboxSettingsWorkingHours.StartTime = tOd;
TimeOfDay tOdE = new TimeOfDay(end.Hour, end.Minute, end.Second);
mailboxSettingsWorkingHours.EndTime = tOdE;

GraphServiceClient.Users[roomCalendarId].Request().Select("MailboxSettings").UpdateAsync(obj).Wait();

通过 Micrsoft Graph 我从特定日历获取 MailboxSettings,但是当我想更新 MailboxSetting 时,我收到错误消息

Via Micrsoft Graph I get the MailboxSettings from a specific calendar, but when I want to update the MailboxSetting I get the Error Message

目标实体集当前不支持该请求".

"The Request is currntly not supported on the targed entity set".

推荐答案

SDK 目前不支持.您将需要进行显式的 http 调用来实现这一点.

This is not currently supported by the SDK. You will need to make explicit http calls to achieve this.

以下是通过邮箱设置更新时区的代码:

Following is the code to update the timezone through mailbox settings:

Uri Uri = new Uri("https://graph.microsoft.com/v1.0/users/"+ user.Id 
          +"/mailboxSettings");
String jsonContent = "{"timeZone" : ""+ timezone +""}";
HttpContent httpContent = new StringContent(jsonContent, System.Text.Encoding.UTF8, "application/json");
await _httpClient.PatchAsync(Uri, httpContent);

您可以使用 http://restsharp.org/ 轻松进行 http 调用.

You can use http://restsharp.org/ to make http calls easily.

这篇关于如何使用 Microsoft Graph API 更新 MailboxSettings的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)