Use this API to add an attachment to an existing event. 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
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.ReadWrite
Delegated (personal Microsoft account)
Calendars.ReadWrite
Application
Calendars.ReadWrite
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
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
Authorization
string
Bearer {token}. Required.
Content-Type
string
Nature of the data in the body of an entity. Required.
Request body
In the request body, supply a JSON representation of attachment object.
Response
If successful, this method returns 201 Created response code and attachment object in the response body.
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new FileAttachment
{
OdataType = "#microsoft.graph.fileAttachment",
Name = "menu.txt",
ContentBytes = Convert.FromBase64String("base64bWFjIGFuZCBjaGVlc2UgdG9kYXk="),
};
var result = await graphClient.Me.Events["{event-id}"].Attachments.PostAsync(requestBody);
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new FileAttachment();
$requestBody->setOdataType('#microsoft.graph.fileAttachment');
$requestBody->setName('menu.txt');
$requestBody->setContentBytes(\GuzzleHttp\Psr7\Utils::streamFor(base64_decode('base64bWFjIGFuZCBjaGVlc2UgdG9kYXk=')));
$result = $graphServiceClient->me()->events()->byEventId('event-id')->attachments()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Calendar
$params = @{
"@odata.type" = "#microsoft.graph.fileAttachment"
name = "menu.txt"
contentBytes = "base64bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
# A UPN can also be used as -UserId.
New-MgUserEventAttachment -UserId $userId -EventId $eventId -BodyParameter $params
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(request_adapter)
request_body = FileAttachment(
odata_type = "#microsoft.graph.fileAttachment",
name = "menu.txt",
content_bytes = base64.urlsafe_b64decode("base64bWFjIGFuZCBjaGVlc2UgdG9kYXk="),
)
result = await graph_client.me.events.by_event_id('event-id').attachments.post(body = request_body)
POST https://graph.microsoft.com/v1.0/me/events/AAMkAGI1AAAt9AHjAAA=/attachments
Content-type: application/json
{
"@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"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new ItemAttachment
{
OdataType = "#microsoft.graph.itemAttachment",
Name = "Holiday event",
Item = new Event
{
OdataType = "microsoft.graph.event",
Subject = "Discuss gifts for children",
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "Let's look for funding!",
},
Start = new DateTimeTimeZone
{
DateTime = "2016-12-02T18:00:00",
TimeZone = "Pacific Standard Time",
},
End = new DateTimeTimeZone
{
DateTime = "2016-12-02T19:00:00",
TimeZone = "Pacific Standard Time",
},
},
};
var result = await graphClient.Me.Events["{event-id}"].Attachments.PostAsync(requestBody);
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ItemAttachment();
$requestBody->setOdataType('#microsoft.graph.itemAttachment');
$requestBody->setName('Holiday event');
$item = new Event();
$item->setOdataType('microsoft.graph.event');
$item->setSubject('Discuss gifts for children');
$itemBody = new ItemBody();
$itemBody->setContentType(new BodyType('hTML'));
$itemBody->setContent('Let\'s look for funding!');
$item->setBody($itemBody);
$itemStart = new DateTimeTimeZone();
$itemStart->setDateTime('2016-12-02T18:00:00');
$itemStart->setTimeZone('Pacific Standard Time');
$item->setStart($itemStart);
$itemEnd = new DateTimeTimeZone();
$itemEnd->setDateTime('2016-12-02T19:00:00');
$itemEnd->setTimeZone('Pacific Standard Time');
$item->setEnd($itemEnd);
$requestBody->setItem($item);
$result = $graphServiceClient->me()->events()->byEventId('event-id')->attachments()->post($requestBody)->wait();