APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
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
POST /me/events/{id}/attachments
POST /users/{id | userPrincipalName}/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.
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var attachment = new FileAttachment
{
Name = "menu.txt",
ContentBytes = Convert.FromBase64String("bWFjIGFuZCBjaGVlc2UgdG9kYXk=")
};
await graphClient.Me.Events["{event-id}"].Attachments
.Request()
.AddAsync(attachment);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := graphmodels.NewAttachment()
"@odata.type" := "#microsoft.graph.fileAttachment"
requestBody.Set"@odata.type"(&"@odata.type")
name := "menu.txt"
requestBody.SetName(&name)
additionalData := map[string]interface{}{
"contentBytes" : "bWFjIGFuZCBjaGVlc2UgdG9kYXk=",
}
requestBody.SetAdditionalData(additionalData)
result, err := graphClient.Me().EventsById("event-id").Attachments().Post(requestBody)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Import-Module Microsoft.Graph.Calendar
$params = @{
"@odata.type" = "#microsoft.graph.fileAttachment"
Name = "menu.txt"
ContentBytes = "bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
# A UPN can also be used as -UserId.
New-MgUserEventAttachment -UserId $userId -EventId $eventId -BodyParameter $params
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?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' => 'bWFjIGFuZCBjaGVlc2UgdG9kYXk=',
];
$requestBody->setAdditionalData($additionalData);
$requestResult = $graphServiceClient->me()->eventsById('event-id')->attachments()->post($requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
POST https://graph.microsoft.com/beta/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"
}
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var attachment = new ItemAttachment
{
Name = "Holiday event",
Item = new 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"
}
}
};
await graphClient.Me.Events["{event-id}"].Attachments
.Request()
.AddAsync(attachment);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
ItemAttachment attachment = new ItemAttachment();
attachment.name = "Holiday event";
Event item = new Event();
item.subject = "Discuss gifts for children";
ItemBody body = new ItemBody();
body.contentType = BodyType.HTML;
body.content = "Let's look for funding!";
item.body = body;
DateTimeTimeZone start = new DateTimeTimeZone();
start.dateTime = "2016-12-02T18:00:00";
start.timeZone = "Pacific Standard Time";
item.start = start;
DateTimeTimeZone end = new DateTimeTimeZone();
end.dateTime = "2016-12-02T19:00:00";
end.timeZone = "Pacific Standard Time";
item.end = end;
attachment.item = item;
graphClient.me().events("AAMkAGI1AAAt9AHjAAA=").attachments()
.buildRequest()
.post(attachment);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := graphmodels.NewAttachment()
"@odata.type" := "#microsoft.graph.itemAttachment"
requestBody.Set"@odata.type"(&"@odata.type")
name := "Holiday event"
requestBody.SetName(&name)
additionalData := map[string]interface{}{
item := graphmodels.New()
"@odata.type" := "microsoft.graph.event"
item.Set"@odata.type"(&"@odata.type")
subject := "Discuss gifts for children"
item.SetSubject(&subject)
body := graphmodels.New()
contentType := "HTML"
body.SetContentType(&contentType)
content := "Let's look for funding!"
body.SetContent(&content)
item.SetBody(body)
start := graphmodels.New()
dateTime := "2016-12-02T18:00:00"
start.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
start.SetTimeZone(&timeZone)
item.SetStart(start)
end := graphmodels.New()
dateTime := "2016-12-02T19:00:00"
end.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
end.SetTimeZone(&timeZone)
item.SetEnd(end)
requestBody.SetItem(item)
}
requestBody.SetAdditionalData(additionalData)
result, err := graphClient.Me().EventsById("event-id").Attachments().Post(requestBody)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Import-Module Microsoft.Graph.Calendar
$params = @{
"@odata.type" = "#microsoft.graph.itemAttachment"
Name = "Holiday event"
Item = @{
"@odata.type" = "microsoft.graph.event"
Subject = "Discuss gifts for children"
}
}
# A UPN can also be used as -UserId.
New-MgUserEventAttachment -UserId $userId -EventId $eventId -BodyParameter $params
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?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);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var attachment = new ReferenceAttachment
{
Name = "Personal pictures",
SourceUrl = "https://contoso.com/personal/mario_contoso_net/Documents/Pics",
ProviderType = ReferenceAttachmentProvider.OneDriveConsumer,
Permission = ReferenceAttachmentPermission.Edit,
IsFolder = true
};
await graphClient.Me.Events["{event-id}"].Attachments
.Request()
.AddAsync(attachment);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := graphmodels.NewAttachment()
"@odata.type" := "#microsoft.graph.referenceAttachment"
requestBody.Set"@odata.type"(&"@odata.type")
name := "Personal pictures"
requestBody.SetName(&name)
additionalData := map[string]interface{}{
"sourceUrl" : "https://contoso.com/personal/mario_contoso_net/Documents/Pics",
"providerType" : "oneDriveConsumer",
"permission" : "Edit",
"isFolder" : "True",
}
requestBody.SetAdditionalData(additionalData)
result, err := graphClient.Me().EventsById("event-id").Attachments().Post(requestBody)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Import-Module Microsoft.Graph.Calendar
$params = @{
"@odata.type" = "#microsoft.graph.referenceAttachment"
Name = "Personal pictures"
SourceUrl = "https://contoso.com/personal/mario_contoso_net/Documents/Pics"
ProviderType = "oneDriveConsumer"
Permission = "Edit"
IsFolder = "True"
}
# A UPN can also be used as -UserId.
New-MgUserEventAttachment -UserId $userId -EventId $eventId -BodyParameter $params
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?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.referenceAttachment');
$requestBody->setName('Personal pictures');
$additionalData = [
'sourceUrl' => 'https://contoso.com/personal/mario_contoso_net/Documents/Pics',
'providerType' => 'oneDriveConsumer',
'permission' => 'Edit',
'isFolder' => 'True',
];
$requestBody->setAdditionalData($additionalData);
$requestResult = $graphServiceClient->me()->eventsById('event-id')->attachments()->post($requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.