Use esta API para agregar datos adjuntos a un evento existente. Esta operación limita el tamaño de los datos adjuntos que puede agregar a menos de 3 MB.
Si un organizador agrega datos adjuntos a un evento de reunión, el organizador también puede actualizar el evento para enviar los datos adjuntos y actualizar el evento para cada asistente.
Elija el permiso o los permisos marcados como con privilegios mínimos para esta API. Use un permiso o permisos con privilegios superiores solo si la aplicación lo requiere. Para obtener más información sobre los permisos delegados y de aplicación, consulte Tipos de permisos. Para obtener más información sobre estos permisos, consulte la referencia de permisos.
Tipo de permiso
Permisos con privilegios mínimos
Permisos con privilegios más altos
Delegado (cuenta profesional o educativa)
Calendars.ReadWrite
No disponible.
Delegado (cuenta personal de Microsoft)
Calendars.ReadWrite
No disponible.
Aplicación
Calendars.ReadWrite
No disponible.
Solicitud HTTP
Datos adjuntos de un evento en el calendario predeterminado del usuario.
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
Encabezados de solicitud
Nombre
Tipo
Descripción
Authorization
string
{token} de portador. Obligatorio.
Content-Type
string
Naturaleza de los datos en el cuerpo de una entidad. Obligatorio.
Cuerpo de solicitud
En el cuerpo de la solicitud, proporcione una representación JSON del objeto attachment.
Respuesta
Si se ejecuta correctamente, este método devuelve el código de respuesta 201 Created y el objeto attachment en el cuerpo de la respuesta.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new FileAttachment
{
OdataType = "#microsoft.graph.fileAttachment",
Name = "menu.txt",
ContentBytes = Convert.FromBase64String("base64bWFjIGFuZCBjaGVlc2UgdG9kYXk="),
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Events["{event-id}"].Attachments.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
FileAttachment attachment = new FileAttachment();
attachment.setOdataType("#microsoft.graph.fileAttachment");
attachment.setName("menu.txt");
byte[] contentBytes = Base64.getDecoder().decode("base64bWFjIGFuZCBjaGVlc2UgdG9kYXk=");
attachment.setContentBytes(contentBytes);
Attachment result = graphClient.me().events().byEventId("{event-id}").attachments().post(attachment);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\FileAttachment;
$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
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
// Dependencies
using Microsoft.Graph.Models;
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",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Events["{event-id}"].Attachments.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
ItemAttachment attachment = new ItemAttachment();
attachment.setOdataType("#microsoft.graph.itemAttachment");
attachment.setName("Holiday event");
Event item = new Event();
item.setOdataType("microsoft.graph.event");
item.setSubject("Discuss gifts for children");
ItemBody body = new ItemBody();
body.setContentType(BodyType.Html);
body.setContent("Let's look for funding!");
item.setBody(body);
DateTimeTimeZone start = new DateTimeTimeZone();
start.setDateTime("2016-12-02T18:00:00");
start.setTimeZone("Pacific Standard Time");
item.setStart(start);
DateTimeTimeZone end = new DateTimeTimeZone();
end.setDateTime("2016-12-02T19:00:00");
end.setTimeZone("Pacific Standard Time");
item.setEnd(end);
attachment.setItem(item);
Attachment result = graphClient.me().events().byEventId("{event-id}").attachments().post(attachment);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\ItemAttachment;
use Microsoft\Graph\Generated\Models\Event;
use Microsoft\Graph\Generated\Models\ItemBody;
use Microsoft\Graph\Generated\Models\DateTimeTimeZone;
$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();
Próximamente: A lo largo de 2024 iremos eliminando gradualmente GitHub Issues como mecanismo de comentarios sobre el contenido y lo sustituiremos por un nuevo sistema de comentarios. Para más información, vea: https://aka.ms/ContentUserFeedback.