How can I Update the MailboxSettings with Microsoft Graph API

醉酒当歌 提交于 2020-01-30 11:45:30

问题


I want to update the MailboxSettings from different calendar.

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

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

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


回答1:


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

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



来源:https://stackoverflow.com/questions/54249432/how-can-i-update-the-mailboxsettings-with-microsoft-graph-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!