添付ファイルを追加Add attachment

名前空間: microsoft.graphNamespace: microsoft.graph

この API を使用して、既存のイベント添付ファイルを追加します。Use this API to add an attachment to an existing event. この操作によって、追加できる添付ファイルのサイズが 3 MB 未満に制限されます。This operation limits the size of the attachment you can add to under 3 MB.

開催者が会議イベントに添付ファイルを追加すると、開催者は後でイベントを 更新 して添付物を送信し、各出席者のイベントも更新することができます。If an organizer adds an attachment to a meeting event, the organizer can subsequently update the event to send the attachment and update the event for each attendee as well.

アクセス許可Permissions

この API を呼び出すには、次のいずれかのアクセス許可が必要です。アクセス許可の選択方法などの詳細については、「アクセス許可」を参照してください。One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.

アクセス許可の種類Permission type アクセス許可 (特権の小さいものから大きいものへ)Permissions (from least to most privileged)
委任 (職場または学校のアカウント)Delegated (work or school account) Calendars.ReadWriteCalendars.ReadWrite
委任 (個人用 Microsoft アカウント)Delegated (personal Microsoft account) Calendars.ReadWriteCalendars.ReadWrite
アプリケーションApplication Calendars.ReadWriteCalendars.ReadWrite

HTTP 要求HTTP request

ユーザーの既定のカレンダー内のイベントの添付ファイル。Attachments for an event in the user's default calendar.

POST /me/events/{id}/attachments
POST /users/{id | userPrincipalName}/events/{id}/attachments

POST /me/calendar/events/{id}/attachments
POST /users/{id | userPrincipalName}/calendar/events/{id}/attachments

ユーザーの既定 calendarGroup に属するカレンダーイベントの添付ファイル。Attachments for an event in a calendar belonging to the user's default calendarGroup.

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

POST /me/calendargroup/calendars/{id}/events/{id}/attachments
POST /users/{id | userPrincipalName}/calendargroup/calendars/{id}/events/{id}/attachments

ユーザーの calendarGroup に属するカレンダーイベントの添付ファイル。Attachments for an event in a calendar belonging to a user's calendarGroup.

POST /me/calendargroups/{id}/calendars/{id}/events/{id}/attachments
POST /users/{id | userPrincipalName}/calendargroups/{id}/calendars/{id}/events/{id}/attachments

要求ヘッダーRequest headers

名前Name 種類Type 説明Description
AuthorizationAuthorization stringstring ベアラー {トークン}。必須。Bearer {token}. Required.
Content-TypeContent-Type stringstring エンティティ本文内のデータの性質です。必須。Nature of the data in the body of an entity. Required.

要求本文Request body

要求本文で、attachment オブジェクトの JSON 表記を指定します。In the request body, supply a JSON representation of attachment object.

応答Response

成功した場合、このメソッドは 201 Created 応答コードと、応答本文で attachment オブジェクトを返します。If successful, this method returns 201 Created response code and attachment object in the response body.

例 (添付ファイル)Example (file attachment)

要求Request

以下は、要求の例です。Here is an example of the request.

POST https://graph.microsoft.com/v1.0/me/events/AAMkAGI1AAAt9AHjAAA=/attachments
Content-type: application/json
Content-length: 151

{
    "@odata.type": "#microsoft.graph.fileAttachment",
    "name": "menu.txt",
    "contentBytes": "base64bWFjIGFuZCBjaGVlc2UgdG9kYXk="   
}

要求本文で、Attachment オブジェクトの JSON 表記を指定します。In the request body, supply a JSON representation of attachment object.

応答Response

以下は、応答の例です。Here is an example of the response.

HTTP 201 Created
Content-type: application/json

{
    "@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('cd209b0b-3f83-4c35-82d2-d88a61820480')/events('AAMkAGI1AAAt9AHjAAA%3D')/attachments/$entity",
    "@odata.type":"#microsoft.graph.fileAttachment",
    "id":"AAMkAGI1AAAt9AHjAAABEgAQAEdBogju-MJEu6Ngg-1_W0g=",
    "lastModifiedDateTime":"2017-04-15T03:21:49Z",
    "name":"menu.txt",
    "contentType":"text/plain",
    "size":178,
    "isInline":false,
    "contentId":null,
    "contentLocation":null,
    "contentBytes":"bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}

例 (項目の添付ファイル)Example (item attachment)

要求Request

以下は、アイテムの添付ファイルとしてイベントを別のイベントに添付する例です。Here is an example which attaches an event with another event as an item attachment.

POST https://graph.microsoft.com/v1.0/me/events/AAMkAGI1AAAt9AHjAAA=/attachments
Content-type: application/json
Content-length: 600

{
  "@odata.type": "#microsoft.graph.itemAttachment",
  "name": "Holiday event", 
  "item": {
        "@odata.type": "microsoft.graph.event",
        "subject": "Discuss gifts for children",
        "body": {
            "contentType": "HTML",
            "content": "Let's look for funding!"
         },
         "start": {
             "dateTime": "2016-12-02T18:00:00",
             "timeZone": "Pacific Standard Time"
          },
          "end": {
             "dateTime": "2016-12-02T19:00:00",
             "timeZone": "Pacific Standard Time"
          }
    }
}
応答Response

以下は、応答の例です。Here is an example of the response.

HTTP 201 Created
Content-type: application/json
Content-length: 162

{
    "@odata.context":"https://graph.microsoft.com/v1.0/$metadata#me/events('AAMkAGI1AAAt9AHjAAA=')/attachments/$entity",
    "@odata.type":"#microsoft.graph.itemAttachment",
    "@odata.id":"https://graph.microsoft.com/v1.0/users('fdcbcf34-2505-4d07-be5b-0a55b699d157@41a5b830-45ac-4f1b-9bfc-baafa3b7db2e')/events('AAMkAGI1AAAt9AHjAAA=')/attachments('AAMkADNkN2Jp5JVnQIe9r0=')",
    "id":"AAMkADNkNJp5JVnQIe9r0=",
    "lastModifiedDateTime":"2016-12-01T22:27:13Z",
    "name":"Holiday event",
    "contentType":null,
    "size":2473,
    "isInline":false
}