更新日历Update calendar

命名空间:microsoft.graphNamespace: microsoft.graph

更新 calendar 对象的属性。Update the properties of a calendar object. 日历可以是用户的一个,也可以是 Microsoft 365的默认日历。The calendar can be one for a user, or the default calendar of a Microsoft 365 group.

权限Permissions

根据事件所处日历类型和所请求的权限类型(委派型或应用程序),需要下列某一权限来调用此 API。Depending on the type of calendar that the event is in and the permission type (delegated or application) requested, one of the following permissions is required to call this API. 要了解详细信息(包括如何选择权限),请参阅权限To learn more, including how to choose permissions, see Permissions.

日历Calendar 委派(工作或学校帐户)Delegated (work or school account) 委派(个人 Microsoft 帐户)Delegated (personal Microsoft account) 应用程序Application
用户日历user calendar Calendars.ReadWriteCalendars.ReadWrite Calendars.ReadWriteCalendars.ReadWrite Calendars.ReadWriteCalendars.ReadWrite
组日历group calendar Group.ReadWrite.AllGroup.ReadWrite.All 不支持。Not supported. 不支持。Not supported.

HTTP 请求HTTP request

用户或组的默认 日历A user's or group's default calendar.

PATCH /me/calendar
PATCH /users/{id | userPrincipalName}/calendar
PATCH /groups/{id}/calendar

默认 calendarGroup 中用户的 日历A user's calendar in the default calendarGroup.

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

PATCH /me/calendarGroup/calendars/{id}
PATCH /users/{id | userPrincipalName}/calendarGroup/calendars/{id}

指定 calendarGroup 中用户的 日历A user's calendar in a specific calendarGroup.

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

请求标头Request headers

标头Header Value
AuthorizationAuthorization Bearer {token}.Bearer {token}. Required.Required.
Content-TypeContent-Type application/json.application/json. Required.Required.

请求正文Request body

In the request body, supply the values for relevant fields that should be updated.In the request body, supply the values for relevant fields that should be updated. Existing properties that are not included in the request body will maintain their previous values or be recalculated based on changes to other property values.Existing properties that are not included in the request body will maintain their previous values or be recalculated based on changes to other property values. For best performance you shouldn't include existing values that haven't changed.For best performance you shouldn't include existing values that haven't changed.

属性Property 类型Type 说明Description
colorcolor StringString Specifies the color theme to distinguish the calendar from other calendars in a UI.Specifies the color theme to distinguish the calendar from other calendars in a UI. The property values are: LightBlue=0, LightGreen=1, LightOrange=2, LightGray=3, LightYellow=4, LightTeal=5, LightPink=6, LightBrown=7, LightRed=8, MaxColor=9, Auto=-1The property values are: LightBlue=0, LightGreen=1, LightOrange=2, LightGray=3, LightYellow=4, LightTeal=5, LightPink=6, LightBrown=7, LightRed=8, MaxColor=9, Auto=-1
namename StringString 日历名称。The calendar name.

响应Response

如果成功,此方法在响应正文中返回 200 OK 响应代码和更新的 calendar 对象。If successful, this method returns a 200 OK response code and updated calendar object in the response body.

示例Example

请求Request

下面的示例更新已登录用户的默认日历的名称。The following example updates the name of the signed-in user's default calendar.

PATCH https://graph.microsoft.com/v1.0/me/calendar
Content-type: application/json

{
  "name": "Social events"
}

响应Response

Here is an example of the response.Here is an example of the response. Note: The response object shown here may be truncated for brevity.Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.All of the properties will be returned from an actual call.

HTTP/1.1 200 OK
Content-type: application/json

{
    "@odata.context":"https://graph.microsoft.com/v1.0/$metadata#me/calendars/$entity",
    "@odata.id":"https://graph.microsoft.com/v1.0/users('266efe5a-0fd7-4edd-877b-b2d1e561f193@ae01a323-3934-4475-a32d-af1274312bb0')/calendars('AAMkADJmMVAAA=')",
    "id":"AAMkADJmMVAAA=",
    "name":"Social events",
    "color":"auto",
    "changeKey":"DxYSthXJXEWwAQSYQnXvIgAAIxGttg==",
    "canShare":true,
    "canViewPrivateItems":true,
    "canEdit":true,
    "allowedOnlineMeetingProviders": [
                "teamsForBusiness"
            ],
    "defaultOnlineMeetingProvider": "teamsForBusiness",
    "isTallyingResponses": true,
    "isRemovable": false,
    "owner":{
        "name":"Samantha Booth",
        "address":"samanthab@adatum.onmicrosoft.com"
    }
}