简体   繁体   English

如何使用 Microsoft Graph API 更新邮箱设置

[英]How can I Update the MailboxSettings with Microsoft Graph API

I want to update the MailboxSettings from different calendar.我想从不同的日历更新 MailboxSettings。

How Can I build the Request that I can update the MailboxSetting via Microsoft Graph?如何构建可以通过 Microsoft Graph 更新 MailboxSetting 的请求?

Here is my code example with the exception:这是我的代码示例,但有例外:

带有异常的代码示例

The code example:代码示例:

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();

Via Micrsoft Graph I get the MailboxSettings from a specific calendar, but when I want to update the MailboxSetting I get the Error Message通过 Micrsoft Graph,我从特定日历中获取 MailboxSettings,但是当我想更新 MailboxSetting 时,我收到错误消息

"The Request is currntly not supported on the targed entity set". “目标实体集目前不支持该请求”。

This is not currently supported by the SDK. SDK 当前不支持此功能。 You will need to make explicit http calls to achieve this.您将需要进行明确的 http 调用来实现这一点。

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);

You can use http://restsharp.org/ to make http calls easily.您可以使用http://restsharp.org/轻松进行 http 调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 /me/mailboxSettings/timeZone 返回的 Microsoft Graph API 的时区值中获取 UTC 偏移量? - How to get UTC offset from Microsoft Graph API's timezone value returned from /me/mailboxSettings/timeZone? Microsoft Graph API - 如何使用“skiptoken” - Microsoft Graph API - How can I use 'skiptoken' 如何通过 C Sharp 中的图形 API 获取 Microsoft 个人资料图片 - How can I GET the Microsoft Profile Picture through the Graph API in C Sharp 如何在不需要管理员权限的情况下访问Microsoft Graph API中已登录用户的组? - How can I access the signed in user's groups in Microsoft's Graph API without needing admin priviledges? Microsoft Graph API - 更新现有组 - Microsoft Graph API - Update Existing Group 如何利用 Microsoft.Graph 更新 Autopilot 信息? - How do I leverage Microsoft.Graph to update Autopilot information? 如何在wexflow中更新执行图 - how can I update execution graph in wexflow 如何从 Microsoft Graph API 中提取 Planner 信息并将数据插入到我的 C#.NET Windows 表单中? - How can I pull Planner information from the Microsoft Graph API and insert the data into my C#.NET Windows form? 如何访问 Microsoft Graph 的 isOnlineMeeting 属性? - How can I access Microsoft Graph's isOnlineMeeting property? 如何在 powershell 中使用 Microsoft Graph .NET SDK? - How can i use Microsoft Graph .NET SDK in powershell?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM