创建日历

命名空间:microsoft.graph

重要

Microsoft Graph /beta 版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。

此 API 可用于在用户的日历组中新建日历。

此 API 可用于以下国家级云部署

全局服务 美国政府 L4 美国政府 L5 (DOD) 由世纪互联运营的中国

权限

要调用此 API,需要以下权限之一。 若要了解详细信息,包括如何选择权限的信息,请参阅权限

权限类型 权限(从最低特权到最高特权)
委派(工作或学校帐户) Calendars.ReadWrite
委派(个人 Microsoft 帐户) Calendars.ReadWrite
应用程序 Calendars.ReadWrite

HTTP 请求

用户的默认 calendarGroup

POST /me/calendars
POST /users/{id | userPrincipalName}/calendars

用户的任意 calendarGroup

POST /me/calendarGroups/{id}/calendars
POST /users/{id | userPrincipalName}/calendarGroups/{id}/calendars

请求标头

标头
Authorization 持有者 {token}。 必填。 详细了解 身份验证和授权
Content-Type application/json. 必需。

请求正文

在请求正文中,提供 calendar 对象的 JSON 表示形式。

响应

如果成功,此方法在响应正文中返回 201 Created 响应代码和 calendar 对象。

示例

请求

以下示例显示了一个请求。

POST https://graph.microsoft.com/beta/me/calendarGroups/AAMkADYAAAR9NR5AAA=/calendars
Content-type: application/json

{
  "name": "Marketing calendar"
}

在请求正文中,提供 calendar 对象的 JSON 表示形式。

响应

以下示例显示了相应的响应。 注意:为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#users('68ca8ec0-11f8-456b-a785-70d9936650d5')/calendarGroups('AAMkADYAAAR9NR5AAA%3D')/calendars/$entity",
    "id": "AAMkADYCQM0GfRAAAcrRD-AAA=",
    "name": "Marketing calendar",
    "color": "auto",
    "changeKey": "4xTfgHLeDkOqYVAkDNBn0QAAHKl46A==",
    "canShare": true,
    "canViewPrivateItems": true,
    "canEdit": true,
    "owner": {
        "name": "Adele Vance",
        "address": "adelev@contoso.com"
    }
}