イベントを取得する

名前空間: microsoft.graph

指定したイベント オブジェクトのプロパティとリレーションシップを取得します。

現在、この操作によって返されるイベントの本文は HTML 形式のみです。

アプリが別のユーザーの予定表のイベントを取得できるシナリオが 2 つあります。

  • アプリにアプリケーションのアクセス許可がある場合。または
  • あるユーザーからアプリに適切な代理アクセス許可が付与され、別のユーザーがそのユーザーと予定表を共有しているか、そのユーザーに代理アクセスを付与している場合。「詳細と例」を参照してください。

event リソースは 拡張機能をサポートしているため、GET 操作を使用して、event インスタンスでカスタム プロパティと拡張機能データを取得することもできます。

さまざまなタイム ゾーンをサポートします。

イベントを返す GET 操作の場合は、すべての操作で Prefer: outlook.timezone ヘッダーを使用して、応答のイベントの開始時刻と終了時刻のタイム ゾーンを指定できます。

たとえば、次の Prefer: outlook.timezone ヘッダーは、応答の開始時刻と終了時刻を東部標準時に設定します。

Prefer: outlook.timezone="Eastern Standard Time"

イベントが別のタイム ゾーンで作成された場合は、開始時刻と終了時刻は Prefer ヘッダーで指定したタイム ゾーンに合わせて調整されます。サポートされているタイム ゾーン名については、この一覧を参照してください。Prefer: outlook.timezone ヘッダーを指定しない場合、開始時刻と終了時刻は UTC で返されます。

イベント リソース上で OriginalStartTimeZone プロパティと OriginalEndTimeZone プロパティを使用して、イベント作成時に使用されたタイム ゾーンを検索できます。

アクセス許可

この API を呼び出すには、次のいずれかのアクセス許可が必要です。アクセス許可の選択方法などの詳細については、「アクセス許可」を参照してください。

アクセス許可の種類 アクセス許可 (特権の小さいものから大きいものへ)
委任 (職場または学校のアカウント) Calendars.Read
委任 (個人用 Microsoft アカウント) Calendars.Read
アプリケーション Calendars.Read

HTTP 要求

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

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

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

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

オプションのクエリ パラメーター

このメソッドは、応答をカスタマイズするための OData クエリ パラメーターをサポートします。

要求ヘッダー

名前 種類 説明
Authorization string ベアラー {token}。必須。
優先: outlook.timezone string これを使用して、応答内の開始および終了時刻のタイム ゾーンを指定します。指定しなかった場合、時刻の値は UTC で返されます。オプション。
Prefer: outlook.body-content-type string body プロパティが返されるときの形式です。 値は、"text" または "html" になります。 この Prefer ヘッダーが指定されている場合、Preference-Applied ヘッダーが確認として返されます。 このヘッダーが指定されていない場合は、body プロパティが HTML 形式で返されます。 省略可能。

要求本文

このメソッドには、要求本文を指定しません。

応答

成功した場合、このメソッドは 200 OK 応答コードと、応答本文でイベント オブジェクトを返します。

要求 1

最初の例では、指定されたイベントを取得します。以下のものを指定します。

  • 太平洋標準時で返される日時の値を取得するための Prefer: outlook.timezone ヘッダー。
  • 特定のプロパティを返すための $select クエリ パラメーター。$select パラメーターを使用しないと、すべてのイベント プロパティが返されます。
GET https://graph.microsoft.com/v1.0/me/events/AAMkAGIAAAoZDOFAAA=?$select=subject,body,bodyPreview,organizer,attendees,start,end,location,hideAttendees 
Prefer: outlook.timezone="Pacific Standard Time"
応答 1

以下は、応答の例です。body プロパティが HTML の既定の形式で返されます。

HTTP/1.1 200 OK
Content-type: application/json
Preference-Applied: outlook.timezone="Pacific Standard Time"

{
    "@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('cd209b0b-3f83-4c35-82d2-d88a61820480')/events(subject,body,bodyPreview,organizer,attendees,start,end,location,hideAttendees)/$entity",
    "@odata.etag":"W/\"ZlnW4RIAV06KYYwlrfNZvQAAKGWwbw==\"",
    "id":"AAMkAGIAAAoZDOFAAA=",
    "subject":"Orientation ",
    "bodyPreview":"Dana, this is the time you selected for our orientation. Please bring the notes I sent you.",
    "body":{
        "contentType":"html",
        "content":"<html><head></head><body><p>Dana, this is the time you selected for our orientation. Please bring the notes I sent you.</p></body></html>"
    },
    "start":{
        "dateTime":"2017-04-21T10:00:00.0000000",
        "timeZone":"Pacific Standard Time"
    },
    "end":{
        "dateTime":"2017-04-21T12:00:00.0000000",
        "timeZone":"Pacific Standard Time"
    },
    "location": {
        "displayName": "Assembly Hall",
        "locationType": "default",
        "uniqueId": "Assembly Hall",
        "uniqueIdType": "private"
    },
    "locations": [
        {
            "displayName": "Assembly Hall",
            "locationType": "default",
            "uniqueIdType": "unknown"
        }
    ],
    "attendees":[
        {
            "type":"required",
            "status":{
                "response":"none",
                "time":"0001-01-01T00:00:00Z"
            },
            "emailAddress":{
                "name":"Samantha Booth",
                "address":"samanthab@a830edad905084922E17020313.onmicrosoft.com"
            }
        },
        {
            "type":"required",
            "status":{
                "response":"tentativelyAccepted",
                "time":"0001-01-01T00:00:00Z"
            },
            "proposedNewTime": {
                "start": {
                    "dateTime": "2019-08-16T12:00:00.0000000",
                    "timeZone": "Pacific Standard Time"
                },
                "end": {
                    "dateTime": "2019-08-16T14:00:00.0000000",
                    "timeZone": "Pacific Standard Time"
                }
            },
            "emailAddress":{
                "name":"Dana Swope",
                "address":"danas@a830edad905084922E17020313.onmicrosoft.com"
            }
        }
    ],
    "hideAttendees": false,
    "organizer":{
        "emailAddress":{
            "name":"Samantha Booth",
            "address":"samanthab@a830edad905084922E17020313.onmicrosoft.com"
        }
    }
}
要求 2

2 番目の例では、複数の場所を指定するイベントを取得する方法を示します。 この要求では、特定のプロパティを返すように $select クエリ パラメーターを指定しています。

GET https://graph.microsoft.com/v1.0/me/events/AAMkADAGAADDdm4NAAA=?$select=subject,body,bodyPreview,organizer,attendees,start,end,location,locations
応答 2

locations プロパティには、イベントを開催する 3 つの場所の詳細が含まれています。

要求では Prefer: outlook.timezone ヘッダーを指定していないため、start および end プロパティは既定の UTC タイム ゾーンで表示されます。

イベントの本文は、既定の HTML 形式になっています。

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

{
  "@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('d1a2fae9-db66-4cc9-8133-2184c77af1b8')/events(subject,body,bodyPreview,organizer,attendees,start,end,location,locations)/$entity",
  "@odata.etag":"W/\"y53lbKh6jkaxHzFwGhgyxgAAw5zhug==\"",
  "id":"AAMkADAGAADDdm4NAAA=",
  "subject":"Plan summer company picnic",
  "bodyPreview":"Let's kick-start this event planning!",
  "body":{
    "contentType":"html",
    "content":"<html>\r\n<head>\r\n</head>\r\n<body>\r\nLet's kick-start this event planning!\r\n</body>\r\n</html>\r\n"
  },
  "start":{
    "dateTime":"2017-08-30T11:00:00.0000000",
    "timeZone":"UTC"
  },
  "end":{
    "dateTime":"2017-08-30T12:00:00.0000000",
    "timeZone":"UTC"
  },
  "location":{
    "displayName":"Conf Room 3; Fourth Coffee; Home Office",
    "locationType":"default",
    "uniqueId":"Conf Room 3; Fourth Coffee; Home Office",
    "uniqueIdType":"private"
  },
  "locations":[
    {
      "displayName":"Conf Room 3",
      "locationType":"default",
      "uniqueIdType":"unknown"
    },
    {
      "displayName":"Fourth Coffee",
      "locationType":"default",
      "uniqueId":"Fourth Coffee",
      "uniqueIdType":"private",
      "address":{
        "street":"4567 Main St",
        "city":"Redmond",
        "state":"WA",
        "countryOrRegion":"US",
        "postalCode":"32008"
      },
      "coordinates":{
        "latitude":47.672,
        "longitude":-102.103
      }
    },
    {
      "displayName":"Home Office",
      "locationType":"default",
      "uniqueIdType":"unknown"
    }
  ],
  "attendees":[
    {
      "type":"required",
      "status":{
        "response":"none",
        "time":"0001-01-01T00:00:00Z"
      },
      "emailAddress":{
        "name":"Dana Swope",
        "address":"DanaS@contoso.onmicrosoft.com"
      }
    },
    {
      "type":"required",
      "status":{
        "response":"none",
        "time":"0001-01-01T00:00:00Z"
      },
      "emailAddress":{
        "name":"Alex Wilber",
        "address":"AlexW@contoso.onmicrosoft.com"
      }
    }
  ],
  "organizer":{
    "emailAddress":{
      "name":"Adele Vance",
      "address":"AdeleV@contoso.onmicrosoft.com"
    }
  }
}

関連項目