[英]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.