简体   繁体   English

通过Microsoft Graph API创建主类别

[英]Create Master Category Via Microsoft Graph API

Im Trying to create a new category via an event for outlook. 我试图通过展望事件创建一个新类别。 Below is what I have so far. 以下是我到目前为止的情况。

  using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AdviserBearerToken);
                client.DefaultRequestHeaders.Accep.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                var categoryName = new List<string>();
                categoryName.Add("New Event");

                var startTime = new Time();
                var endTime = new Time();
                startTime.DateTime = "2016-07-15T15:00:00.0000000";
                startTime.TimeZone = "UTC";
                endTime.DateTime = "2016-07-15T15:30:00.0000000";
                endTime.TimeZone = "UTC";

                var eventModel = new EventModelForGraph
                {
                    categories = categoryName,
                    subject = "This is an event",
                    Start = startTime,
                    End = endTime

                };
                var serializedObject = JsonConvert.SerializeObject(eventModel);
                var createBody = new StringContent(serializedObject, System.Text.Encoding.UTF8, "application/json");
                var response = await client.PostAsync("https://graph.microsoft.com/v1.0/me/calendar/events", createBody);

                var responseString = await response.Content.ReadAsStringAsync();
            }

The event shows up in the calendar and the category as the header but it is not listed under the categorize tab which leads me to my question. 该事件显示在日历中,而类别显示为标题,但未列在分类标签下,这引出了我的问题。 Is it possible to create such a category using the API? 是否可以使用API​​创建这样的类别?

No, you cannot add categories to the master category list via the REST API. 不,您无法通过REST API将类别添加到主类别列表中。 You cannot add them directly via any API. 您无法通过任何API直接添加它们。

However, you CAN modify the list if you're willing to manipulate the XML directly. 但是,如果您愿意直接操作XML,则可以修改列表。 The gory details are documented in MS-OXOCFG . 血腥细节记录在MS-OXOCFG中 You can use EWS for example to access the config item. 例如,您可以使用EWS访问配置项。

This would be a great feature to add to the REST API. 这将是添加到REST API的一个很棒的功能。 You should suggest it on UserVoice . 您应该在UserVoice上建议它。

I know this is an older question, but I was looking into the same thing and figured I'd post an update. 我知道这是一个较老的问题,但我正在研究同样的事情,并认为我会发布更新。 This is now possible with the current version of the Graph API. 现在,使用当前版本的Graph API可以实现这一点。 You can see the documentation here from MSDN. 您可以 MSDN中查看此处的文档。 You can create categories by sending a POST API request: 您可以通过发送POST API请求来创建类别:

POST https://graph.microsoft.com/beta/me/outlook/masterCategories
Content-type: application/json
Content-Length: 70

{
      "displayName":"Project expenses",
      "color":"preset9"
}

After the category is created, you can assign it when you create your event by adding the category's displayName property to the categories collection of the item. 创建类别后,您可以在创建事件时通过将类别的displayName属性添加到项目的categories集合来分配它。

You can find more details about when these API endpoints were added here and more details about categories here . 你可以发现,当添加这些API端点的更多细节在这里和有关类别的详细信息在这里

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

相关问题 Microsoft Graph - Teams API 在 Graph Explorer 上工作,但不能通过代码 - Microsoft Graph - Teams API works on Graph Explorer but not via code Microsoft Graph API客户端库-创建文件夹 - Microsoft Graph API client library - create a folder 无法通过 Microsoft Graph API(C# 控制台)发送电子邮件 - Unable to send email via Microsoft Graph API (C# Console) 如何使用 C# 通过 Microsoft Graph 使用模板 educationClass 创建团队 - How to create a team with template educationClass via Microsoft Graph with C# 是否可以通过 Microsoft Graph 创建 Azure RBAC 角色 - Is it possible to create Azure RBAC role via Microsoft Graph Microsoft Graph API Microsoft 登录 - Microsoft Graph API Microsoft Login Microsoft Graph API 在 Azure AD 中创建用户得到 500 错误 - Microsoft Graph API Create User in Azure AD gets 500 error 使用 Microsoft Graph API 创建“在线会议活动”或仅在线会议 - Create a 'event as online meeting' or only the onlineMeeting using Microsoft Graph API 如何使用microsoft graph api在日历中创建事件? - how to create event in calendor using microsoft graph api? Microsoft graph API创建文件夹,使用返回“ invalidRequest”的路径 - Microsoft graph api create folder using path returning 'invalidRequest'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM