获取日历Get calendar

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

获取 calendar 对象的属性和关系。Get the properties and relationships of a calendar object. 可以是用户的日历,也可以是 Microsoft 365 的默认日历。The calendar can be one for a user, or the default calendar of a Microsoft 365 group.

在下列两种情况下,应用可获取其他用户的日历:There are two scenarios where an app can get another user's calendar:

  • 如果该应用具有应用程序权限,或者If the app has application permissions, or,
  • 如果应用程序具有来自某个用户的相应委派权限,而另一个用户与该用户共享了日历,或者已为该用户授予委派的访问权限。If the app has the appropriate delegated permissions from one user, and another user has shared a calendar with that user, or, has given delegated access to that user. 请参阅详细信息和示例See details and an example.

权限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.Read、Calendars.ReadWriteCalendars.Read, Calendars.ReadWrite Calendars.Read、Calendars.ReadWriteCalendars.Read, Calendars.ReadWrite Calendars.Read、Calendars.ReadWriteCalendars.Read, Calendars.ReadWrite
组日历group calendar Group.Read.All、Group.ReadWrite.AllGroup.Read.All, Group.ReadWrite.All 不支持。Not supported. 不支持。Not supported.

HTTP 请求HTTP request

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

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

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

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

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

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

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

可选的查询参数Optional query parameters

此方法支持 OData 查询参数 来帮助自定义响应。This method supports the OData Query Parameters to help customize the response.

请求标头Request headers

名称Name 类型Type 说明Description
AuthorizationAuthorization stringstring Bearer {token}。必需。Bearer {token}. Required.

请求正文Request body

请勿提供此方法的请求正文。Do not supply a request body for this method.

响应Response

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

示例Example

请求Request

下面的示例提供了登录用户的默认日历。The following example gets the signed-in user's default calendar.

GET https://graph.microsoft.com/v1.0/me/calendar

响应Response

下面是一个响应示例。注意:为了简单起见,可能会将此处所示的响应对象截断。将从实际调用中返回所有属性。Here is an example of the response. Note: The response object shown here may be truncated for brevity. 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('ddfcd489-628b-40d7-b48b-57002df800e5@1717622f-1d94-4d0c-9d74-709fad664b77')/calendars('AAMkAGI2TGuLAAA=')",
    "id": "AAMkAGI2TGuLAAA=",
    "name": "Calendar",
    "color": "auto",
    "changeKey": "nfZyf7VcrEKLNoU37KWlkQAAA0x0+w==",
    "canShare":true,
    "canViewPrivateItems":true,
    "canEdit":true,
    "allowedOnlineMeetingProviders": [
                "teamsForBusiness"
            ],
    "defaultOnlineMeetingProvider": "teamsForBusiness",
    "isTallyingResponses": true,
    "isRemovable": false,
    "owner":{
        "name":"Samantha Booth",
        "address":"samanthab@adatum.onmicrosoft.com"
    }
}