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.
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Attachment
{
OdataType = "#microsoft.graph.fileAttachment",
Name = "menu.txt",
AdditionalData = new Dictionary<string, object>
{
{
"contentBytes" , "base64bWFjIGFuZCBjaGVlc2UgdG9kYXk="
},
},
};
var result = await graphClient.Me.Events["{event-id}"].Attachments.PostAsync(requestBody);
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
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new Attachment();
$requestBody->set@odatatype('#microsoft.graph.fileAttachment');
$requestBody->setName('menu.txt');
$additionalData = [
'contentBytes' => 'base64bWFjIGFuZCBjaGVlc2UgdG9kYXk=',
];
$requestBody->setAdditionalData($additionalData);
$requestResult = $graphServiceClient->me()->eventsById('event-id')->attachments()->post($requestBody);
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"
}
}
}
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Attachment
{
OdataType = "#microsoft.graph.itemAttachment",
Name = "Holiday event",
AdditionalData = new Dictionary<string, object>
{
{
"item" , new
{
OdataType = "microsoft.graph.event",
Subject = "Discuss gifts for children",
Body = new
{
ContentType = "HTML",
Content = "Let's look for funding!",
},
Start = new
{
DateTime = "2016-12-02T18:00:00",
TimeZone = "Pacific Standard Time",
},
End = new
{
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 FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new Attachment();
$requestBody->set@odatatype('#microsoft.graph.itemAttachment');
$requestBody->setName('Holiday event');
$additionalData = [
'item' => $requestBody = new Item();
$ requestBody->set@odatatype('microsoft.graph.event');
$ requestBody->setSubject('Discuss gifts for children');
$body = new Body();
$ body->setContentType('HTML');
$ body->setContent('Let\'s look for funding!');
$requestBody->setBody($body);
$start = new Start();
$ start->setDateTime('2016-12-02T18:00:00');
$ start->setTimeZone('Pacific Standard Time');
$requestBody->setStart($start);
$end = new End();
$ end->setDateTime('2016-12-02T19:00:00');
$ end->setTimeZone('Pacific Standard Time');
$requestBody->setEnd($end);
$requestBody->setItem($item);
];
$requestBody->setAdditionalData($additionalData);
$requestResult = $graphServiceClient->me()->eventsById('event-id')->attachments()->post($requestBody);