Las API de la versión /beta de Microsoft Graph están sujetas a cambios. No se admite el uso de estas API en aplicaciones de producción. Para determinar si una API está disponible en la versión 1.0, use el selector de Versión.
Cree un evento en el calendario predeterminado del usuario o en un calendario especificado.
De forma predeterminada, la propiedad allowNewTimeProposals se establece en verdadero cuando se crea un evento, lo que significa que los invitados pueden proponer una fecha u hora diferente para el evento. Para más información sobre cómo proponer una hora y cómo recibir o aceptar una nueva propuesta de hora, consulte Proponer nuevas horas de reunión.
Puede especificar la zona horaria de cada una de las horas de inicio y finalización del evento como parte de estos valores, ya que las propiedades start y end son del tipo dateTimeTimeZone. En primer lugar, busque las zonas horarias compatibles para asegurarse de que solo se configuren zonas horarias configuradas para el servidor de buzones del usuario.
Cuando se envía un evento, el servidor envía invitaciones a todos los asistentes.
Definir la ubicación de un evento
Un administrador de Exchange puede configurar un buzón y una dirección de correo electrónico para un recurso, como una sala de reuniones, o equipamiento, como un proyector. Los usuarios pueden luego invitar al recurso como asistente a una reunión. En nombre de recurso, el servidor acepta o rechaza la convocatoria de reunión en función de la programación de disponibilidad del recurso.
Si el servidor acepta una reunión para el recurso, se crea un evento de la reunión en el calendario del recurso. Si se vuelve a programar la reunión, el servidor actualiza automáticamente el evento en el calendario del recurso.
Otra ventaja de configurar un buzón para un recurso es controlar la programación del recurso; por ejemplo, solo los ejecutivos o los delegados pueden reservar una sala de reuniones privadas.
Si se organiza un evento que implica una ubicación de la reunión:
Configure la propiedad location del evento en consecuencia.
Establezca la propiedad locationEmailAddress si la ubicación de la reunión tiene una dirección de correo electrónico.
Además, si la ubicación de la reunión se ha configurado como recurso o el evento implica equipos que se han configurado como recurso:
Se requiere uno de los siguientes permisos para llamar a esta API. Para obtener más información, incluido cómo elegir permisos, vea Permisos.
Tipo de permiso
Permisos (de menos a más privilegiados)
Delegado (cuenta profesional o educativa)
Calendars.ReadWrite
Delegado (cuenta personal de Microsoft)
Calendars.ReadWrite
Aplicación
Calendars.ReadWrite
Solicitud HTTP
POST /me/events
POST /users/{id | userPrincipalName}/events
POST /me/calendar/events
POST /users/{id | userPrincipalName}/calendar/events
POST /me/calendars/{id}/events
POST /users/{id | userPrincipalName}/calendars/{id}/events
En el cuerpo de la solicitud, proporcione una representación JSON del objeto de evento .
Dado que el recurso event admite extensiones, puede utilizar la operación POST y agregar propiedades personalizadas con sus propios datos al evento al crearla.
Respuesta
Si se ejecuta correctamente, este método devuelve 201 Created el código de respuesta y un objeto de evento en el cuerpo de la respuesta.
Ejemplos
Ejemplo 1: Creación de un evento en la zona horaria especificada y asignación del evento a un valor transactionId opcional
Solicitud
En el ejemplo siguiente se muestra la solicitud. Usa el encabezado de solicitud Prefer: outlook.timezone para especificar la zona horaria de las horas de inicio y finalización en la respuesta. También configura la propiedad transactionId para reducir los reintentos innecesarios en el servidor.
POST https://graph.microsoft.com/beta/me/events
Prefer: outlook.timezone="Pacific Standard Time"
Content-type: application/json
{
"subject": "Let's go for lunch",
"body": {
"contentType": "HTML",
"content": "Does noon work for you?"
},
"start": {
"dateTime": "2017-04-15T12:00:00",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2017-04-15T14:00:00",
"timeZone": "Pacific Standard Time"
},
"location":{
"displayName":"Harry's Bar"
},
"attendees": [
{
"emailAddress": {
"address":"samanthab@contoso.com",
"name": "Samantha Booth"
},
"type": "required"
}
],
"allowNewTimeProposals": true,
"transactionId":"7E163156-7762-4BEB-A1C6-729EA81755A7"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Event
{
Subject = "Let's go for lunch",
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "Does noon work for you?",
},
Start = new DateTimeTimeZone
{
DateTime = "2017-04-15T12:00:00",
TimeZone = "Pacific Standard Time",
},
End = new DateTimeTimeZone
{
DateTime = "2017-04-15T14:00:00",
TimeZone = "Pacific Standard Time",
},
Location = new Location
{
DisplayName = "Harry's Bar",
},
Attendees = new List<Attendee>
{
new Attendee
{
EmailAddress = new EmailAddress
{
Address = "samanthab@contoso.com",
Name = "Samantha Booth",
},
Type = AttendeeType.Required,
},
},
AllowNewTimeProposals = true,
TransactionId = "7E163156-7762-4BEB-A1C6-729EA81755A7",
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Events.PostAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Prefer", "outlook.timezone=\"Pacific Standard Time\"");
});
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("Prefer", "outlook.timezone=\"Pacific Standard Time\"")
configuration := &graphusers.ItemEventsRequestBuilderPostRequestConfiguration{
Headers: headers,
}
requestBody := graphmodels.NewEvent()
subject := "Let's go for lunch"
requestBody.SetSubject(&subject)
body := graphmodels.NewItemBody()
contentType := graphmodels.HTML_BODYTYPE
body.SetContentType(&contentType)
content := "Does noon work for you?"
body.SetContent(&content)
requestBody.SetBody(body)
start := graphmodels.NewDateTimeTimeZone()
dateTime := "2017-04-15T12:00:00"
start.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
start.SetTimeZone(&timeZone)
requestBody.SetStart(start)
end := graphmodels.NewDateTimeTimeZone()
dateTime := "2017-04-15T14:00:00"
end.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
end.SetTimeZone(&timeZone)
requestBody.SetEnd(end)
location := graphmodels.NewLocation()
displayName := "Harry's Bar"
location.SetDisplayName(&displayName)
requestBody.SetLocation(location)
attendee := graphmodels.NewAttendee()
emailAddress := graphmodels.NewEmailAddress()
address := "samanthab@contoso.com"
emailAddress.SetAddress(&address)
name := "Samantha Booth"
emailAddress.SetName(&name)
attendee.SetEmailAddress(emailAddress)
type := graphmodels.REQUIRED_ATTENDEETYPE
attendee.SetType(&type)
attendees := []graphmodels.Attendeeable {
attendee,
}
requestBody.SetAttendees(attendees)
allowNewTimeProposals := true
requestBody.SetAllowNewTimeProposals(&allowNewTimeProposals)
transactionId := "7E163156-7762-4BEB-A1C6-729EA81755A7"
requestBody.SetTransactionId(&transactionId)
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
events, err := graphClient.Me().Events().Post(context.Background(), requestBody, configuration)
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Event event = new Event();
event.setSubject("Let's go for lunch");
ItemBody body = new ItemBody();
body.setContentType(BodyType.Html);
body.setContent("Does noon work for you?");
event.setBody(body);
DateTimeTimeZone start = new DateTimeTimeZone();
start.setDateTime("2017-04-15T12:00:00");
start.setTimeZone("Pacific Standard Time");
event.setStart(start);
DateTimeTimeZone end = new DateTimeTimeZone();
end.setDateTime("2017-04-15T14:00:00");
end.setTimeZone("Pacific Standard Time");
event.setEnd(end);
Location location = new Location();
location.setDisplayName("Harry's Bar");
event.setLocation(location);
LinkedList<Attendee> attendees = new LinkedList<Attendee>();
Attendee attendee = new Attendee();
EmailAddress emailAddress = new EmailAddress();
emailAddress.setAddress("samanthab@contoso.com");
emailAddress.setName("Samantha Booth");
attendee.setEmailAddress(emailAddress);
attendee.setType(AttendeeType.Required);
attendees.add(attendee);
event.setAttendees(attendees);
event.setAllowNewTimeProposals(true);
event.setTransactionId("7E163156-7762-4BEB-A1C6-729EA81755A7");
Event result = graphClient.me().events().post(event, requestConfiguration -> {
requestConfiguration.headers.add("Prefer", "outlook.timezone=\"Pacific Standard Time\"");
});
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Events\EventsRequestBuilderPostRequestConfiguration;
use Microsoft\Graph\Beta\Generated\Models\Event;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\BodyType;
use Microsoft\Graph\Beta\Generated\Models\DateTimeTimeZone;
use Microsoft\Graph\Beta\Generated\Models\Location;
use Microsoft\Graph\Beta\Generated\Models\Attendee;
use Microsoft\Graph\Beta\Generated\Models\EmailAddress;
use Microsoft\Graph\Beta\Generated\Models\AttendeeType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Event();
$requestBody->setSubject('Let\'s go for lunch');
$body = new ItemBody();
$body->setContentType(new BodyType('hTML'));
$body->setContent('Does noon work for you?');
$requestBody->setBody($body);
$start = new DateTimeTimeZone();
$start->setDateTime('2017-04-15T12:00:00');
$start->setTimeZone('Pacific Standard Time');
$requestBody->setStart($start);
$end = new DateTimeTimeZone();
$end->setDateTime('2017-04-15T14:00:00');
$end->setTimeZone('Pacific Standard Time');
$requestBody->setEnd($end);
$location = new Location();
$location->setDisplayName('Harry\'s Bar');
$requestBody->setLocation($location);
$attendeesAttendee1 = new Attendee();
$attendeesAttendee1EmailAddress = new EmailAddress();
$attendeesAttendee1EmailAddress->setAddress('samanthab@contoso.com');
$attendeesAttendee1EmailAddress->setName('Samantha Booth');
$attendeesAttendee1->setEmailAddress($attendeesAttendee1EmailAddress);
$attendeesAttendee1->setType(new AttendeeType('required'));
$attendeesArray []= $attendeesAttendee1;
$requestBody->setAttendees($attendeesArray);
$requestBody->setAllowNewTimeProposals(true);
$requestBody->setTransactionId('7E163156-7762-4BEB-A1C6-729EA81755A7');
$requestConfiguration = new EventsRequestBuilderPostRequestConfiguration();
$headers = [
'Prefer' => 'outlook.timezone="Pacific Standard Time"',
];
$requestConfiguration->headers = $headers;
$result = $graphServiceClient->me()->events()->post($requestBody, $requestConfiguration)->wait();
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Import-Module Microsoft.Graph.Beta.Calendar
$params = @{
subject = "Let's go for lunch"
body = @{
contentType = "HTML"
content = "Does noon work for you?"
}
start = @{
dateTime = "2017-04-15T12:00:00"
timeZone = "Pacific Standard Time"
}
end = @{
dateTime = "2017-04-15T14:00:00"
timeZone = "Pacific Standard Time"
}
location = @{
displayName = "Harry's Bar"
}
attendees = @(
@{
emailAddress = @{
address = "samanthab@contoso.com"
name = "Samantha Booth"
}
type = "required"
}
)
allowNewTimeProposals = $true
transactionId = "7E163156-7762-4BEB-A1C6-729EA81755A7"
}
# A UPN can also be used as -UserId.
New-MgBetaUserEvent -UserId $userId -BodyParameter $params
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.events.events_request_builder import EventsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
from msgraph_beta.generated.models.event import Event
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.body_type import BodyType
from msgraph_beta.generated.models.date_time_time_zone import DateTimeTimeZone
from msgraph_beta.generated.models.location import Location
from msgraph_beta.generated.models.attendee import Attendee
from msgraph_beta.generated.models.email_address import EmailAddress
from msgraph_beta.generated.models.attendee_type import AttendeeType
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Event(
subject = "Let's go for lunch",
body = ItemBody(
content_type = BodyType.Html,
content = "Does noon work for you?",
),
start = DateTimeTimeZone(
date_time = "2017-04-15T12:00:00",
time_zone = "Pacific Standard Time",
),
end = DateTimeTimeZone(
date_time = "2017-04-15T14:00:00",
time_zone = "Pacific Standard Time",
),
location = Location(
display_name = "Harry's Bar",
),
attendees = [
Attendee(
email_address = EmailAddress(
address = "samanthab@contoso.com",
name = "Samantha Booth",
),
type = AttendeeType.Required,
),
],
allow_new_time_proposals = True,
transaction_id = "7E163156-7762-4BEB-A1C6-729EA81755A7",
)
request_configuration = RequestConfiguration()
request_configuration.headers.add("Prefer", "outlook.timezone=\"Pacific Standard Time\"")
result = await graph_client.me.events.post(request_body, request_configuration = request_configuration)
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
En el ejemplo siguiente se muestra la respuesta que muestra cómo las propiedades start y end usan la zona horaria especificada en el Prefer: outlook.timezone encabezado.
Nota: Se puede acortar el objeto de respuesta que se muestra aquí para mejorar la legibilidad.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Event
{
Subject = "Plan summer company picnic",
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "Let's kick-start this event planning!",
},
Start = new DateTimeTimeZone
{
DateTime = "2017-08-30T11:00:00",
TimeZone = "Pacific Standard Time",
},
End = new DateTimeTimeZone
{
DateTime = "2017-08-30T12:00:00",
TimeZone = "Pacific Standard Time",
},
Attendees = new List<Attendee>
{
new Attendee
{
EmailAddress = new EmailAddress
{
Address = "DanaS@contoso.com",
Name = "Dana Swope",
},
Type = AttendeeType.Required,
},
new Attendee
{
EmailAddress = new EmailAddress
{
Address = "AlexW@contoso.com",
Name = "Alex Wilber",
},
Type = AttendeeType.Required,
},
},
Location = new Location
{
DisplayName = "Conf Room 3; Fourth Coffee; Home Office",
LocationType = LocationType.Default,
},
Locations = new List<Location>
{
new Location
{
DisplayName = "Conf Room 3",
},
new Location
{
DisplayName = "Fourth Coffee",
Address = new PhysicalAddress
{
Street = "4567 Main St",
City = "Redmond",
State = "WA",
CountryOrRegion = "US",
PostalCode = "32008",
},
Coordinates = new OutlookGeoCoordinates
{
Latitude = 47.672d,
Longitude = -102.103d,
},
},
new Location
{
DisplayName = "Home Office",
},
},
AllowNewTimeProposals = true,
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Events.PostAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Prefer", "outlook.timezone=\"Pacific Standard Time\"");
});
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("Prefer", "outlook.timezone=\"Pacific Standard Time\"")
configuration := &graphusers.ItemEventsRequestBuilderPostRequestConfiguration{
Headers: headers,
}
requestBody := graphmodels.NewEvent()
subject := "Plan summer company picnic"
requestBody.SetSubject(&subject)
body := graphmodels.NewItemBody()
contentType := graphmodels.HTML_BODYTYPE
body.SetContentType(&contentType)
content := "Let's kick-start this event planning!"
body.SetContent(&content)
requestBody.SetBody(body)
start := graphmodels.NewDateTimeTimeZone()
dateTime := "2017-08-30T11:00:00"
start.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
start.SetTimeZone(&timeZone)
requestBody.SetStart(start)
end := graphmodels.NewDateTimeTimeZone()
dateTime := "2017-08-30T12:00:00"
end.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
end.SetTimeZone(&timeZone)
requestBody.SetEnd(end)
attendee := graphmodels.NewAttendee()
emailAddress := graphmodels.NewEmailAddress()
address := "DanaS@contoso.com"
emailAddress.SetAddress(&address)
name := "Dana Swope"
emailAddress.SetName(&name)
attendee.SetEmailAddress(emailAddress)
type := graphmodels.REQUIRED_ATTENDEETYPE
attendee.SetType(&type)
attendee1 := graphmodels.NewAttendee()
emailAddress := graphmodels.NewEmailAddress()
address := "AlexW@contoso.com"
emailAddress.SetAddress(&address)
name := "Alex Wilber"
emailAddress.SetName(&name)
attendee1.SetEmailAddress(emailAddress)
type := graphmodels.REQUIRED_ATTENDEETYPE
attendee1.SetType(&type)
attendees := []graphmodels.Attendeeable {
attendee,
attendee1,
}
requestBody.SetAttendees(attendees)
location := graphmodels.NewLocation()
displayName := "Conf Room 3; Fourth Coffee; Home Office"
location.SetDisplayName(&displayName)
locationType := graphmodels.DEFAULT_LOCATIONTYPE
location.SetLocationType(&locationType)
requestBody.SetLocation(location)
location := graphmodels.NewLocation()
displayName := "Conf Room 3"
location.SetDisplayName(&displayName)
location1 := graphmodels.NewLocation()
displayName := "Fourth Coffee"
location1.SetDisplayName(&displayName)
address := graphmodels.NewPhysicalAddress()
street := "4567 Main St"
address.SetStreet(&street)
city := "Redmond"
address.SetCity(&city)
state := "WA"
address.SetState(&state)
countryOrRegion := "US"
address.SetCountryOrRegion(&countryOrRegion)
postalCode := "32008"
address.SetPostalCode(&postalCode)
location1.SetAddress(address)
coordinates := graphmodels.NewOutlookGeoCoordinates()
latitude := float64(47.672)
coordinates.SetLatitude(&latitude)
longitude := float64(-102.103)
coordinates.SetLongitude(&longitude)
location1.SetCoordinates(coordinates)
location2 := graphmodels.NewLocation()
displayName := "Home Office"
location2.SetDisplayName(&displayName)
locations := []graphmodels.Locationable {
location,
location1,
location2,
}
requestBody.SetLocations(locations)
allowNewTimeProposals := true
requestBody.SetAllowNewTimeProposals(&allowNewTimeProposals)
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
events, err := graphClient.Me().Events().Post(context.Background(), requestBody, configuration)
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Event event = new Event();
event.setSubject("Plan summer company picnic");
ItemBody body = new ItemBody();
body.setContentType(BodyType.Html);
body.setContent("Let's kick-start this event planning!");
event.setBody(body);
DateTimeTimeZone start = new DateTimeTimeZone();
start.setDateTime("2017-08-30T11:00:00");
start.setTimeZone("Pacific Standard Time");
event.setStart(start);
DateTimeTimeZone end = new DateTimeTimeZone();
end.setDateTime("2017-08-30T12:00:00");
end.setTimeZone("Pacific Standard Time");
event.setEnd(end);
LinkedList<Attendee> attendees = new LinkedList<Attendee>();
Attendee attendee = new Attendee();
EmailAddress emailAddress = new EmailAddress();
emailAddress.setAddress("DanaS@contoso.com");
emailAddress.setName("Dana Swope");
attendee.setEmailAddress(emailAddress);
attendee.setType(AttendeeType.Required);
attendees.add(attendee);
Attendee attendee1 = new Attendee();
EmailAddress emailAddress1 = new EmailAddress();
emailAddress1.setAddress("AlexW@contoso.com");
emailAddress1.setName("Alex Wilber");
attendee1.setEmailAddress(emailAddress1);
attendee1.setType(AttendeeType.Required);
attendees.add(attendee1);
event.setAttendees(attendees);
Location location = new Location();
location.setDisplayName("Conf Room 3; Fourth Coffee; Home Office");
location.setLocationType(LocationType.Default);
event.setLocation(location);
LinkedList<Location> locations = new LinkedList<Location>();
Location location1 = new Location();
location1.setDisplayName("Conf Room 3");
locations.add(location1);
Location location2 = new Location();
location2.setDisplayName("Fourth Coffee");
PhysicalAddress address2 = new PhysicalAddress();
address2.setStreet("4567 Main St");
address2.setCity("Redmond");
address2.setState("WA");
address2.setCountryOrRegion("US");
address2.setPostalCode("32008");
location2.setAddress(address2);
OutlookGeoCoordinates coordinates = new OutlookGeoCoordinates();
coordinates.setLatitude(47.672d);
coordinates.setLongitude(-102.103d);
location2.setCoordinates(coordinates);
locations.add(location2);
Location location3 = new Location();
location3.setDisplayName("Home Office");
locations.add(location3);
event.setLocations(locations);
event.setAllowNewTimeProposals(true);
Event result = graphClient.me().events().post(event, requestConfiguration -> {
requestConfiguration.headers.add("Prefer", "outlook.timezone=\"Pacific Standard Time\"");
});
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Events\EventsRequestBuilderPostRequestConfiguration;
use Microsoft\Graph\Beta\Generated\Models\Event;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\BodyType;
use Microsoft\Graph\Beta\Generated\Models\DateTimeTimeZone;
use Microsoft\Graph\Beta\Generated\Models\Attendee;
use Microsoft\Graph\Beta\Generated\Models\EmailAddress;
use Microsoft\Graph\Beta\Generated\Models\AttendeeType;
use Microsoft\Graph\Beta\Generated\Models\Location;
use Microsoft\Graph\Beta\Generated\Models\LocationType;
use Microsoft\Graph\Beta\Generated\Models\PhysicalAddress;
use Microsoft\Graph\Beta\Generated\Models\OutlookGeoCoordinates;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Event();
$requestBody->setSubject('Plan summer company picnic');
$body = new ItemBody();
$body->setContentType(new BodyType('hTML'));
$body->setContent('Let\'s kick-start this event planning!');
$requestBody->setBody($body);
$start = new DateTimeTimeZone();
$start->setDateTime('2017-08-30T11:00:00');
$start->setTimeZone('Pacific Standard Time');
$requestBody->setStart($start);
$end = new DateTimeTimeZone();
$end->setDateTime('2017-08-30T12:00:00');
$end->setTimeZone('Pacific Standard Time');
$requestBody->setEnd($end);
$attendeesAttendee1 = new Attendee();
$attendeesAttendee1EmailAddress = new EmailAddress();
$attendeesAttendee1EmailAddress->setAddress('DanaS@contoso.com');
$attendeesAttendee1EmailAddress->setName('Dana Swope');
$attendeesAttendee1->setEmailAddress($attendeesAttendee1EmailAddress);
$attendeesAttendee1->setType(new AttendeeType('required'));
$attendeesArray []= $attendeesAttendee1;
$attendeesAttendee2 = new Attendee();
$attendeesAttendee2EmailAddress = new EmailAddress();
$attendeesAttendee2EmailAddress->setAddress('AlexW@contoso.com');
$attendeesAttendee2EmailAddress->setName('Alex Wilber');
$attendeesAttendee2->setEmailAddress($attendeesAttendee2EmailAddress);
$attendeesAttendee2->setType(new AttendeeType('required'));
$attendeesArray []= $attendeesAttendee2;
$requestBody->setAttendees($attendeesArray);
$location = new Location();
$location->setDisplayName('Conf Room 3; Fourth Coffee; Home Office');
$location->setLocationType(new LocationType('default'));
$requestBody->setLocation($location);
$locationsLocation1 = new Location();
$locationsLocation1->setDisplayName('Conf Room 3');
$locationsArray []= $locationsLocation1;
$locationsLocation2 = new Location();
$locationsLocation2->setDisplayName('Fourth Coffee');
$locationsLocation2Address = new PhysicalAddress();
$locationsLocation2Address->setStreet('4567 Main St');
$locationsLocation2Address->setCity('Redmond');
$locationsLocation2Address->setState('WA');
$locationsLocation2Address->setCountryOrRegion('US');
$locationsLocation2Address->setPostalCode('32008');
$locationsLocation2->setAddress($locationsLocation2Address);
$locationsLocation2Coordinates = new OutlookGeoCoordinates();
$locationsLocation2Coordinates->setLatitude(47.672);
$locationsLocation2Coordinates->setLongitude(-102.103);
$locationsLocation2->setCoordinates($locationsLocation2Coordinates);
$locationsArray []= $locationsLocation2;
$locationsLocation3 = new Location();
$locationsLocation3->setDisplayName('Home Office');
$locationsArray []= $locationsLocation3;
$requestBody->setLocations($locationsArray);
$requestBody->setAllowNewTimeProposals(true);
$requestConfiguration = new EventsRequestBuilderPostRequestConfiguration();
$headers = [
'Prefer' => 'outlook.timezone="Pacific Standard Time"',
];
$requestConfiguration->headers = $headers;
$result = $graphServiceClient->me()->events()->post($requestBody, $requestConfiguration)->wait();
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.events.events_request_builder import EventsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
from msgraph_beta.generated.models.event import Event
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.body_type import BodyType
from msgraph_beta.generated.models.date_time_time_zone import DateTimeTimeZone
from msgraph_beta.generated.models.attendee import Attendee
from msgraph_beta.generated.models.email_address import EmailAddress
from msgraph_beta.generated.models.attendee_type import AttendeeType
from msgraph_beta.generated.models.location import Location
from msgraph_beta.generated.models.location_type import LocationType
from msgraph_beta.generated.models.physical_address import PhysicalAddress
from msgraph_beta.generated.models.outlook_geo_coordinates import OutlookGeoCoordinates
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Event(
subject = "Plan summer company picnic",
body = ItemBody(
content_type = BodyType.Html,
content = "Let's kick-start this event planning!",
),
start = DateTimeTimeZone(
date_time = "2017-08-30T11:00:00",
time_zone = "Pacific Standard Time",
),
end = DateTimeTimeZone(
date_time = "2017-08-30T12:00:00",
time_zone = "Pacific Standard Time",
),
attendees = [
Attendee(
email_address = EmailAddress(
address = "DanaS@contoso.com",
name = "Dana Swope",
),
type = AttendeeType.Required,
),
Attendee(
email_address = EmailAddress(
address = "AlexW@contoso.com",
name = "Alex Wilber",
),
type = AttendeeType.Required,
),
],
location = Location(
display_name = "Conf Room 3; Fourth Coffee; Home Office",
location_type = LocationType.Default,
),
locations = [
Location(
display_name = "Conf Room 3",
),
Location(
display_name = "Fourth Coffee",
address = PhysicalAddress(
street = "4567 Main St",
city = "Redmond",
state = "WA",
country_or_region = "US",
postal_code = "32008",
),
coordinates = OutlookGeoCoordinates(
latitude = 47.672,
longitude = -102.103,
),
),
Location(
display_name = "Home Office",
),
],
allow_new_time_proposals = True,
)
request_configuration = RequestConfiguration()
request_configuration.headers.add("Prefer", "outlook.timezone=\"Pacific Standard Time\"")
result = await graph_client.me.events.post(request_body, request_configuration = request_configuration)
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
En la siguiente respuesta de ejemplo se muestra el evento creado que especifica información para las tres ubicaciones de la reunión. Debido al encabezado de solicitud Prefer: outlook.timezone="Pacific Standard Time", las propiedades start y end se expresan en el archivo PST.
Nota: Se puede acortar el objeto de respuesta que se muestra aquí para mejorar la legibilidad.
Ejemplo 3: Creación de un evento periódico semanal
Solicitud
El tercer ejemplo muestra cómo crear un evento recurrente que ocurre una vez a la semana. El evento se produce de las 12:00 a las 14:00, todos los lunes a partir del 4 de septiembre de 2017 hasta el final del año.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Event
{
Subject = "Let's go for lunch",
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "Does noon time work for you?",
},
Start = new DateTimeTimeZone
{
DateTime = "2017-09-04T12:00:00",
TimeZone = "Pacific Standard Time",
},
End = new DateTimeTimeZone
{
DateTime = "2017-09-04T14:00:00",
TimeZone = "Pacific Standard Time",
},
Recurrence = new PatternedRecurrence
{
Pattern = new RecurrencePattern
{
Type = RecurrencePatternType.Weekly,
Interval = 1,
DaysOfWeek = new List<DayOfWeekObject?>
{
DayOfWeekObject.Monday,
},
},
Range = new RecurrenceRange
{
Type = RecurrenceRangeType.EndDate,
StartDate = new Date(DateTime.Parse("2017-09-04")),
EndDate = new Date(DateTime.Parse("2017-12-31")),
},
},
Location = new Location
{
DisplayName = "Harry's Bar",
},
Attendees = new List<Attendee>
{
new Attendee
{
EmailAddress = new EmailAddress
{
Address = "AdeleV@contoso.com",
Name = "Adele Vance",
},
Type = AttendeeType.Required,
},
},
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Events.PostAsync(requestBody);
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewEvent()
subject := "Let's go for lunch"
requestBody.SetSubject(&subject)
body := graphmodels.NewItemBody()
contentType := graphmodels.HTML_BODYTYPE
body.SetContentType(&contentType)
content := "Does noon time work for you?"
body.SetContent(&content)
requestBody.SetBody(body)
start := graphmodels.NewDateTimeTimeZone()
dateTime := "2017-09-04T12:00:00"
start.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
start.SetTimeZone(&timeZone)
requestBody.SetStart(start)
end := graphmodels.NewDateTimeTimeZone()
dateTime := "2017-09-04T14:00:00"
end.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
end.SetTimeZone(&timeZone)
requestBody.SetEnd(end)
recurrence := graphmodels.NewPatternedRecurrence()
pattern := graphmodels.NewRecurrencePattern()
type := graphmodels.WEEKLY_RECURRENCEPATTERNTYPE
pattern.SetType(&type)
interval := int32(1)
pattern.SetInterval(&interval)
daysOfWeek := []graphmodels.DayOfWeekable {
dayOfWeek := graphmodels.MONDAY_DAYOFWEEK
pattern.SetDayOfWeek(&dayOfWeek)
}
pattern.SetDaysOfWeek(daysOfWeek)
recurrence.SetPattern(pattern)
range := graphmodels.NewRecurrenceRange()
type := graphmodels.ENDDATE_RECURRENCERANGETYPE
range.SetType(&type)
startDate := 2017-09-04
range.SetStartDate(&startDate)
endDate := 2017-12-31
range.SetEndDate(&endDate)
recurrence.SetRange(range)
requestBody.SetRecurrence(recurrence)
location := graphmodels.NewLocation()
displayName := "Harry's Bar"
location.SetDisplayName(&displayName)
requestBody.SetLocation(location)
attendee := graphmodels.NewAttendee()
emailAddress := graphmodels.NewEmailAddress()
address := "AdeleV@contoso.com"
emailAddress.SetAddress(&address)
name := "Adele Vance"
emailAddress.SetName(&name)
attendee.SetEmailAddress(emailAddress)
type := graphmodels.REQUIRED_ATTENDEETYPE
attendee.SetType(&type)
attendees := []graphmodels.Attendeeable {
attendee,
}
requestBody.SetAttendees(attendees)
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
events, err := graphClient.Me().Events().Post(context.Background(), requestBody, nil)
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Event event = new Event();
event.setSubject("Let's go for lunch");
ItemBody body = new ItemBody();
body.setContentType(BodyType.Html);
body.setContent("Does noon time work for you?");
event.setBody(body);
DateTimeTimeZone start = new DateTimeTimeZone();
start.setDateTime("2017-09-04T12:00:00");
start.setTimeZone("Pacific Standard Time");
event.setStart(start);
DateTimeTimeZone end = new DateTimeTimeZone();
end.setDateTime("2017-09-04T14:00:00");
end.setTimeZone("Pacific Standard Time");
event.setEnd(end);
PatternedRecurrence recurrence = new PatternedRecurrence();
RecurrencePattern pattern = new RecurrencePattern();
pattern.setType(RecurrencePatternType.Weekly);
pattern.setInterval(1);
LinkedList<DayOfWeek> daysOfWeek = new LinkedList<DayOfWeek>();
daysOfWeek.add(DayOfWeek.Monday);
pattern.setDaysOfWeek(daysOfWeek);
recurrence.setPattern(pattern);
RecurrenceRange range = new RecurrenceRange();
range.setType(RecurrenceRangeType.EndDate);
LocalDate startDate = LocalDate.parse("2017-09-04");
range.setStartDate(startDate);
LocalDate endDate = LocalDate.parse("2017-12-31");
range.setEndDate(endDate);
recurrence.setRange(range);
event.setRecurrence(recurrence);
Location location = new Location();
location.setDisplayName("Harry's Bar");
event.setLocation(location);
LinkedList<Attendee> attendees = new LinkedList<Attendee>();
Attendee attendee = new Attendee();
EmailAddress emailAddress = new EmailAddress();
emailAddress.setAddress("AdeleV@contoso.com");
emailAddress.setName("Adele Vance");
attendee.setEmailAddress(emailAddress);
attendee.setType(AttendeeType.Required);
attendees.add(attendee);
event.setAttendees(attendees);
Event result = graphClient.me().events().post(event);
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Event;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\BodyType;
use Microsoft\Graph\Beta\Generated\Models\DateTimeTimeZone;
use Microsoft\Graph\Beta\Generated\Models\PatternedRecurrence;
use Microsoft\Graph\Beta\Generated\Models\RecurrencePattern;
use Microsoft\Graph\Beta\Generated\Models\RecurrencePatternType;
use Microsoft\Graph\Beta\Generated\Models\DayOfWeek;
use Microsoft\Graph\Beta\Generated\Models\RecurrenceRange;
use Microsoft\Graph\Beta\Generated\Models\RecurrenceRangeType;
use Microsoft\Kiota\Abstractions\Types\Date;
use Microsoft\Graph\Beta\Generated\Models\Location;
use Microsoft\Graph\Beta\Generated\Models\Attendee;
use Microsoft\Graph\Beta\Generated\Models\EmailAddress;
use Microsoft\Graph\Beta\Generated\Models\AttendeeType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Event();
$requestBody->setSubject('Let\'s go for lunch');
$body = new ItemBody();
$body->setContentType(new BodyType('hTML'));
$body->setContent('Does noon time work for you?');
$requestBody->setBody($body);
$start = new DateTimeTimeZone();
$start->setDateTime('2017-09-04T12:00:00');
$start->setTimeZone('Pacific Standard Time');
$requestBody->setStart($start);
$end = new DateTimeTimeZone();
$end->setDateTime('2017-09-04T14:00:00');
$end->setTimeZone('Pacific Standard Time');
$requestBody->setEnd($end);
$recurrence = new PatternedRecurrence();
$recurrencePattern = new RecurrencePattern();
$recurrencePattern->setType(new RecurrencePatternType('weekly'));
$recurrencePattern->setInterval(1);
$recurrencePattern->setDaysOfWeek([new DayOfWeek('monday'), ]);
$recurrence->setPattern($recurrencePattern);
$recurrenceRange = new RecurrenceRange();
$recurrenceRange->setType(new RecurrenceRangeType('endDate'));
$recurrenceRange->setStartDate(new Date('2017-09-04'));
$recurrenceRange->setEndDate(new Date('2017-12-31'));
$recurrence->setRange($recurrenceRange);
$requestBody->setRecurrence($recurrence);
$location = new Location();
$location->setDisplayName('Harry\'s Bar');
$requestBody->setLocation($location);
$attendeesAttendee1 = new Attendee();
$attendeesAttendee1EmailAddress = new EmailAddress();
$attendeesAttendee1EmailAddress->setAddress('AdeleV@contoso.com');
$attendeesAttendee1EmailAddress->setName('Adele Vance');
$attendeesAttendee1->setEmailAddress($attendeesAttendee1EmailAddress);
$attendeesAttendee1->setType(new AttendeeType('required'));
$attendeesArray []= $attendeesAttendee1;
$requestBody->setAttendees($attendeesArray);
$result = $graphServiceClient->me()->events()->post($requestBody)->wait();
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Import-Module Microsoft.Graph.Beta.Calendar
$params = @{
subject = "Let's go for lunch"
body = @{
contentType = "HTML"
content = "Does noon time work for you?"
}
start = @{
dateTime = "2017-09-04T12:00:00"
timeZone = "Pacific Standard Time"
}
end = @{
dateTime = "2017-09-04T14:00:00"
timeZone = "Pacific Standard Time"
}
recurrence = @{
pattern = @{
type = "weekly"
interval = 1
daysOfWeek = @(
"Monday"
)
}
range = @{
type = "endDate"
startDate = "2017-09-04"
endDate = "2017-12-31"
}
}
location = @{
displayName = "Harry's Bar"
}
attendees = @(
@{
emailAddress = @{
address = "AdeleV@contoso.com"
name = "Adele Vance"
}
type = "required"
}
)
}
# A UPN can also be used as -UserId.
New-MgBetaUserEvent -UserId $userId -BodyParameter $params
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.event import Event
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.body_type import BodyType
from msgraph_beta.generated.models.date_time_time_zone import DateTimeTimeZone
from msgraph_beta.generated.models.patterned_recurrence import PatternedRecurrence
from msgraph_beta.generated.models.recurrence_pattern import RecurrencePattern
from msgraph_beta.generated.models.recurrence_pattern_type import RecurrencePatternType
from msgraph_beta.generated.models.day_of_week import DayOfWeek
from msgraph_beta.generated.models.recurrence_range import RecurrenceRange
from msgraph_beta.generated.models.recurrence_range_type import RecurrenceRangeType
from msgraph_beta.generated.models.location import Location
from msgraph_beta.generated.models.attendee import Attendee
from msgraph_beta.generated.models.email_address import EmailAddress
from msgraph_beta.generated.models.attendee_type import AttendeeType
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Event(
subject = "Let's go for lunch",
body = ItemBody(
content_type = BodyType.Html,
content = "Does noon time work for you?",
),
start = DateTimeTimeZone(
date_time = "2017-09-04T12:00:00",
time_zone = "Pacific Standard Time",
),
end = DateTimeTimeZone(
date_time = "2017-09-04T14:00:00",
time_zone = "Pacific Standard Time",
),
recurrence = PatternedRecurrence(
pattern = RecurrencePattern(
type = RecurrencePatternType.Weekly,
interval = 1,
days_of_week = [
DayOfWeek.Monday,
],
),
range = RecurrenceRange(
type = RecurrenceRangeType.EndDate,
start_date = "2017-09-04",
end_date = "2017-12-31",
),
),
location = Location(
display_name = "Harry's Bar",
),
attendees = [
Attendee(
email_address = EmailAddress(
address = "AdeleV@contoso.com",
name = "Adele Vance",
),
type = AttendeeType.Required,
),
],
)
result = await graph_client.me.events.post(request_body)
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
El cuarto ejemplo muestra cómo crear un evento diario recurrente. El evento tiene lugar de 12:00 p.m. a 2:00 p.m., todos los días a partir del 25 de febrero de 2020, para dos repeticiones.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Event
{
Subject = "Let's go for lunch",
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "Does noon work for you?",
},
Start = new DateTimeTimeZone
{
DateTime = "2020-02-25T12:00:00",
TimeZone = "Pacific Standard Time",
},
End = new DateTimeTimeZone
{
DateTime = "2020-02-25T14:00:00",
TimeZone = "Pacific Standard Time",
},
Location = new Location
{
DisplayName = "Harry's Bar",
},
Attendees = new List<Attendee>
{
new Attendee
{
EmailAddress = new EmailAddress
{
Address = "AlexW@contoso.com",
Name = "Alex Wilbur",
},
Type = AttendeeType.Required,
},
},
Recurrence = new PatternedRecurrence
{
Pattern = new RecurrencePattern
{
Type = RecurrencePatternType.Daily,
Interval = 1,
},
Range = new RecurrenceRange
{
Type = RecurrenceRangeType.Numbered,
StartDate = new Date(DateTime.Parse("2020-02-25")),
NumberOfOccurrences = 2,
},
},
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Events.PostAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Prefer", "outlook.timezone=\"Pacific Standard Time\"");
});
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("Prefer", "outlook.timezone=\"Pacific Standard Time\"")
configuration := &graphusers.ItemEventsRequestBuilderPostRequestConfiguration{
Headers: headers,
}
requestBody := graphmodels.NewEvent()
subject := "Let's go for lunch"
requestBody.SetSubject(&subject)
body := graphmodels.NewItemBody()
contentType := graphmodels.HTML_BODYTYPE
body.SetContentType(&contentType)
content := "Does noon work for you?"
body.SetContent(&content)
requestBody.SetBody(body)
start := graphmodels.NewDateTimeTimeZone()
dateTime := "2020-02-25T12:00:00"
start.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
start.SetTimeZone(&timeZone)
requestBody.SetStart(start)
end := graphmodels.NewDateTimeTimeZone()
dateTime := "2020-02-25T14:00:00"
end.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
end.SetTimeZone(&timeZone)
requestBody.SetEnd(end)
location := graphmodels.NewLocation()
displayName := "Harry's Bar"
location.SetDisplayName(&displayName)
requestBody.SetLocation(location)
attendee := graphmodels.NewAttendee()
emailAddress := graphmodels.NewEmailAddress()
address := "AlexW@contoso.com"
emailAddress.SetAddress(&address)
name := "Alex Wilbur"
emailAddress.SetName(&name)
attendee.SetEmailAddress(emailAddress)
type := graphmodels.REQUIRED_ATTENDEETYPE
attendee.SetType(&type)
attendees := []graphmodels.Attendeeable {
attendee,
}
requestBody.SetAttendees(attendees)
recurrence := graphmodels.NewPatternedRecurrence()
pattern := graphmodels.NewRecurrencePattern()
type := graphmodels.DAILY_RECURRENCEPATTERNTYPE
pattern.SetType(&type)
interval := int32(1)
pattern.SetInterval(&interval)
recurrence.SetPattern(pattern)
range := graphmodels.NewRecurrenceRange()
type := graphmodels.NUMBERED_RECURRENCERANGETYPE
range.SetType(&type)
startDate := 2020-02-25
range.SetStartDate(&startDate)
numberOfOccurrences := int32(2)
range.SetNumberOfOccurrences(&numberOfOccurrences)
recurrence.SetRange(range)
requestBody.SetRecurrence(recurrence)
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
events, err := graphClient.Me().Events().Post(context.Background(), requestBody, configuration)
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Event event = new Event();
event.setSubject("Let's go for lunch");
ItemBody body = new ItemBody();
body.setContentType(BodyType.Html);
body.setContent("Does noon work for you?");
event.setBody(body);
DateTimeTimeZone start = new DateTimeTimeZone();
start.setDateTime("2020-02-25T12:00:00");
start.setTimeZone("Pacific Standard Time");
event.setStart(start);
DateTimeTimeZone end = new DateTimeTimeZone();
end.setDateTime("2020-02-25T14:00:00");
end.setTimeZone("Pacific Standard Time");
event.setEnd(end);
Location location = new Location();
location.setDisplayName("Harry's Bar");
event.setLocation(location);
LinkedList<Attendee> attendees = new LinkedList<Attendee>();
Attendee attendee = new Attendee();
EmailAddress emailAddress = new EmailAddress();
emailAddress.setAddress("AlexW@contoso.com");
emailAddress.setName("Alex Wilbur");
attendee.setEmailAddress(emailAddress);
attendee.setType(AttendeeType.Required);
attendees.add(attendee);
event.setAttendees(attendees);
PatternedRecurrence recurrence = new PatternedRecurrence();
RecurrencePattern pattern = new RecurrencePattern();
pattern.setType(RecurrencePatternType.Daily);
pattern.setInterval(1);
recurrence.setPattern(pattern);
RecurrenceRange range = new RecurrenceRange();
range.setType(RecurrenceRangeType.Numbered);
LocalDate startDate = LocalDate.parse("2020-02-25");
range.setStartDate(startDate);
range.setNumberOfOccurrences(2);
recurrence.setRange(range);
event.setRecurrence(recurrence);
Event result = graphClient.me().events().post(event, requestConfiguration -> {
requestConfiguration.headers.add("Prefer", "outlook.timezone=\"Pacific Standard Time\"");
});
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Events\EventsRequestBuilderPostRequestConfiguration;
use Microsoft\Graph\Beta\Generated\Models\Event;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\BodyType;
use Microsoft\Graph\Beta\Generated\Models\DateTimeTimeZone;
use Microsoft\Graph\Beta\Generated\Models\Location;
use Microsoft\Graph\Beta\Generated\Models\Attendee;
use Microsoft\Graph\Beta\Generated\Models\EmailAddress;
use Microsoft\Graph\Beta\Generated\Models\AttendeeType;
use Microsoft\Graph\Beta\Generated\Models\PatternedRecurrence;
use Microsoft\Graph\Beta\Generated\Models\RecurrencePattern;
use Microsoft\Graph\Beta\Generated\Models\RecurrencePatternType;
use Microsoft\Graph\Beta\Generated\Models\RecurrenceRange;
use Microsoft\Graph\Beta\Generated\Models\RecurrenceRangeType;
use Microsoft\Kiota\Abstractions\Types\Date;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Event();
$requestBody->setSubject('Let\'s go for lunch');
$body = new ItemBody();
$body->setContentType(new BodyType('hTML'));
$body->setContent('Does noon work for you?');
$requestBody->setBody($body);
$start = new DateTimeTimeZone();
$start->setDateTime('2020-02-25T12:00:00');
$start->setTimeZone('Pacific Standard Time');
$requestBody->setStart($start);
$end = new DateTimeTimeZone();
$end->setDateTime('2020-02-25T14:00:00');
$end->setTimeZone('Pacific Standard Time');
$requestBody->setEnd($end);
$location = new Location();
$location->setDisplayName('Harry\'s Bar');
$requestBody->setLocation($location);
$attendeesAttendee1 = new Attendee();
$attendeesAttendee1EmailAddress = new EmailAddress();
$attendeesAttendee1EmailAddress->setAddress('AlexW@contoso.com');
$attendeesAttendee1EmailAddress->setName('Alex Wilbur');
$attendeesAttendee1->setEmailAddress($attendeesAttendee1EmailAddress);
$attendeesAttendee1->setType(new AttendeeType('required'));
$attendeesArray []= $attendeesAttendee1;
$requestBody->setAttendees($attendeesArray);
$recurrence = new PatternedRecurrence();
$recurrencePattern = new RecurrencePattern();
$recurrencePattern->setType(new RecurrencePatternType('daily'));
$recurrencePattern->setInterval(1);
$recurrence->setPattern($recurrencePattern);
$recurrenceRange = new RecurrenceRange();
$recurrenceRange->setType(new RecurrenceRangeType('numbered'));
$recurrenceRange->setStartDate(new Date('2020-02-25'));
$recurrenceRange->setNumberOfOccurrences(2);
$recurrence->setRange($recurrenceRange);
$requestBody->setRecurrence($recurrence);
$requestConfiguration = new EventsRequestBuilderPostRequestConfiguration();
$headers = [
'Prefer' => 'outlook.timezone="Pacific Standard Time"',
];
$requestConfiguration->headers = $headers;
$result = $graphServiceClient->me()->events()->post($requestBody, $requestConfiguration)->wait();
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Import-Module Microsoft.Graph.Beta.Calendar
$params = @{
subject = "Let's go for lunch"
body = @{
contentType = "HTML"
content = "Does noon work for you?"
}
start = @{
dateTime = "2020-02-25T12:00:00"
timeZone = "Pacific Standard Time"
}
end = @{
dateTime = "2020-02-25T14:00:00"
timeZone = "Pacific Standard Time"
}
location = @{
displayName = "Harry's Bar"
}
attendees = @(
@{
emailAddress = @{
address = "AlexW@contoso.com"
name = "Alex Wilbur"
}
type = "required"
}
)
recurrence = @{
pattern = @{
type = "daily"
interval = 1
}
range = @{
type = "numbered"
startDate = "2020-02-25"
numberOfOccurrences = 2
}
}
}
# A UPN can also be used as -UserId.
New-MgBetaUserEvent -UserId $userId -BodyParameter $params
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.events.events_request_builder import EventsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
from msgraph_beta.generated.models.event import Event
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.body_type import BodyType
from msgraph_beta.generated.models.date_time_time_zone import DateTimeTimeZone
from msgraph_beta.generated.models.location import Location
from msgraph_beta.generated.models.attendee import Attendee
from msgraph_beta.generated.models.email_address import EmailAddress
from msgraph_beta.generated.models.attendee_type import AttendeeType
from msgraph_beta.generated.models.patterned_recurrence import PatternedRecurrence
from msgraph_beta.generated.models.recurrence_pattern import RecurrencePattern
from msgraph_beta.generated.models.recurrence_pattern_type import RecurrencePatternType
from msgraph_beta.generated.models.recurrence_range import RecurrenceRange
from msgraph_beta.generated.models.recurrence_range_type import RecurrenceRangeType
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Event(
subject = "Let's go for lunch",
body = ItemBody(
content_type = BodyType.Html,
content = "Does noon work for you?",
),
start = DateTimeTimeZone(
date_time = "2020-02-25T12:00:00",
time_zone = "Pacific Standard Time",
),
end = DateTimeTimeZone(
date_time = "2020-02-25T14:00:00",
time_zone = "Pacific Standard Time",
),
location = Location(
display_name = "Harry's Bar",
),
attendees = [
Attendee(
email_address = EmailAddress(
address = "AlexW@contoso.com",
name = "Alex Wilbur",
),
type = AttendeeType.Required,
),
],
recurrence = PatternedRecurrence(
pattern = RecurrencePattern(
type = RecurrencePatternType.Daily,
interval = 1,
),
range = RecurrenceRange(
type = RecurrenceRangeType.Numbered,
start_date = "2020-02-25",
number_of_occurrences = 2,
),
),
)
request_configuration = RequestConfiguration()
request_configuration.headers.add("Prefer", "outlook.timezone=\"Pacific Standard Time\"")
result = await graph_client.me.events.post(request_body, request_configuration = request_configuration)
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Ejemplo 5: Creación y habilitación de un evento como una reunión en línea
Solicitud
En el ejemplo siguiente se muestra una solicitud que crea un evento y lo habilita como una reunión en línea. Usa el encabezado de solicitud Prefer: outlook.timezone para especificar la zona horaria de las horas de inicio y finalización en la respuesta.
POST https://graph.microsoft.com/beta/me/events
Prefer: outlook.timezone="Pacific Standard Time"
Content-type: application/json
{
"subject": "Let's go for lunch",
"body": {
"contentType": "HTML",
"content": "Does noon work for you?"
},
"start": {
"dateTime": "2017-04-15T12:00:00",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2017-04-15T14:00:00",
"timeZone": "Pacific Standard Time"
},
"location":{
"displayName":"Harry's Bar"
},
"attendees": [
{
"emailAddress": {
"address":"samanthab@contoso.com",
"name": "Samantha Booth"
},
"type": "required"
}
],
"allowNewTimeProposals": true,
"isOnlineMeeting": true,
"onlineMeetingProvider": "teamsForBusiness"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Event
{
Subject = "Let's go for lunch",
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "Does noon work for you?",
},
Start = new DateTimeTimeZone
{
DateTime = "2017-04-15T12:00:00",
TimeZone = "Pacific Standard Time",
},
End = new DateTimeTimeZone
{
DateTime = "2017-04-15T14:00:00",
TimeZone = "Pacific Standard Time",
},
Location = new Location
{
DisplayName = "Harry's Bar",
},
Attendees = new List<Attendee>
{
new Attendee
{
EmailAddress = new EmailAddress
{
Address = "samanthab@contoso.com",
Name = "Samantha Booth",
},
Type = AttendeeType.Required,
},
},
AllowNewTimeProposals = true,
IsOnlineMeeting = true,
OnlineMeetingProvider = OnlineMeetingProviderType.TeamsForBusiness,
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Events.PostAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Prefer", "outlook.timezone=\"Pacific Standard Time\"");
});
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("Prefer", "outlook.timezone=\"Pacific Standard Time\"")
configuration := &graphusers.ItemEventsRequestBuilderPostRequestConfiguration{
Headers: headers,
}
requestBody := graphmodels.NewEvent()
subject := "Let's go for lunch"
requestBody.SetSubject(&subject)
body := graphmodels.NewItemBody()
contentType := graphmodels.HTML_BODYTYPE
body.SetContentType(&contentType)
content := "Does noon work for you?"
body.SetContent(&content)
requestBody.SetBody(body)
start := graphmodels.NewDateTimeTimeZone()
dateTime := "2017-04-15T12:00:00"
start.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
start.SetTimeZone(&timeZone)
requestBody.SetStart(start)
end := graphmodels.NewDateTimeTimeZone()
dateTime := "2017-04-15T14:00:00"
end.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
end.SetTimeZone(&timeZone)
requestBody.SetEnd(end)
location := graphmodels.NewLocation()
displayName := "Harry's Bar"
location.SetDisplayName(&displayName)
requestBody.SetLocation(location)
attendee := graphmodels.NewAttendee()
emailAddress := graphmodels.NewEmailAddress()
address := "samanthab@contoso.com"
emailAddress.SetAddress(&address)
name := "Samantha Booth"
emailAddress.SetName(&name)
attendee.SetEmailAddress(emailAddress)
type := graphmodels.REQUIRED_ATTENDEETYPE
attendee.SetType(&type)
attendees := []graphmodels.Attendeeable {
attendee,
}
requestBody.SetAttendees(attendees)
allowNewTimeProposals := true
requestBody.SetAllowNewTimeProposals(&allowNewTimeProposals)
isOnlineMeeting := true
requestBody.SetIsOnlineMeeting(&isOnlineMeeting)
onlineMeetingProvider := graphmodels.TEAMSFORBUSINESS_ONLINEMEETINGPROVIDERTYPE
requestBody.SetOnlineMeetingProvider(&onlineMeetingProvider)
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
events, err := graphClient.Me().Events().Post(context.Background(), requestBody, configuration)
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Event event = new Event();
event.setSubject("Let's go for lunch");
ItemBody body = new ItemBody();
body.setContentType(BodyType.Html);
body.setContent("Does noon work for you?");
event.setBody(body);
DateTimeTimeZone start = new DateTimeTimeZone();
start.setDateTime("2017-04-15T12:00:00");
start.setTimeZone("Pacific Standard Time");
event.setStart(start);
DateTimeTimeZone end = new DateTimeTimeZone();
end.setDateTime("2017-04-15T14:00:00");
end.setTimeZone("Pacific Standard Time");
event.setEnd(end);
Location location = new Location();
location.setDisplayName("Harry's Bar");
event.setLocation(location);
LinkedList<Attendee> attendees = new LinkedList<Attendee>();
Attendee attendee = new Attendee();
EmailAddress emailAddress = new EmailAddress();
emailAddress.setAddress("samanthab@contoso.com");
emailAddress.setName("Samantha Booth");
attendee.setEmailAddress(emailAddress);
attendee.setType(AttendeeType.Required);
attendees.add(attendee);
event.setAttendees(attendees);
event.setAllowNewTimeProposals(true);
event.setIsOnlineMeeting(true);
event.setOnlineMeetingProvider(OnlineMeetingProviderType.TeamsForBusiness);
Event result = graphClient.me().events().post(event, requestConfiguration -> {
requestConfiguration.headers.add("Prefer", "outlook.timezone=\"Pacific Standard Time\"");
});
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Events\EventsRequestBuilderPostRequestConfiguration;
use Microsoft\Graph\Beta\Generated\Models\Event;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\BodyType;
use Microsoft\Graph\Beta\Generated\Models\DateTimeTimeZone;
use Microsoft\Graph\Beta\Generated\Models\Location;
use Microsoft\Graph\Beta\Generated\Models\Attendee;
use Microsoft\Graph\Beta\Generated\Models\EmailAddress;
use Microsoft\Graph\Beta\Generated\Models\AttendeeType;
use Microsoft\Graph\Beta\Generated\Models\OnlineMeetingProviderType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Event();
$requestBody->setSubject('Let\'s go for lunch');
$body = new ItemBody();
$body->setContentType(new BodyType('hTML'));
$body->setContent('Does noon work for you?');
$requestBody->setBody($body);
$start = new DateTimeTimeZone();
$start->setDateTime('2017-04-15T12:00:00');
$start->setTimeZone('Pacific Standard Time');
$requestBody->setStart($start);
$end = new DateTimeTimeZone();
$end->setDateTime('2017-04-15T14:00:00');
$end->setTimeZone('Pacific Standard Time');
$requestBody->setEnd($end);
$location = new Location();
$location->setDisplayName('Harry\'s Bar');
$requestBody->setLocation($location);
$attendeesAttendee1 = new Attendee();
$attendeesAttendee1EmailAddress = new EmailAddress();
$attendeesAttendee1EmailAddress->setAddress('samanthab@contoso.com');
$attendeesAttendee1EmailAddress->setName('Samantha Booth');
$attendeesAttendee1->setEmailAddress($attendeesAttendee1EmailAddress);
$attendeesAttendee1->setType(new AttendeeType('required'));
$attendeesArray []= $attendeesAttendee1;
$requestBody->setAttendees($attendeesArray);
$requestBody->setAllowNewTimeProposals(true);
$requestBody->setIsOnlineMeeting(true);
$requestBody->setOnlineMeetingProvider(new OnlineMeetingProviderType('teamsForBusiness'));
$requestConfiguration = new EventsRequestBuilderPostRequestConfiguration();
$headers = [
'Prefer' => 'outlook.timezone="Pacific Standard Time"',
];
$requestConfiguration->headers = $headers;
$result = $graphServiceClient->me()->events()->post($requestBody, $requestConfiguration)->wait();
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
Import-Module Microsoft.Graph.Beta.Calendar
$params = @{
subject = "Let's go for lunch"
body = @{
contentType = "HTML"
content = "Does noon work for you?"
}
start = @{
dateTime = "2017-04-15T12:00:00"
timeZone = "Pacific Standard Time"
}
end = @{
dateTime = "2017-04-15T14:00:00"
timeZone = "Pacific Standard Time"
}
location = @{
displayName = "Harry's Bar"
}
attendees = @(
@{
emailAddress = @{
address = "samanthab@contoso.com"
name = "Samantha Booth"
}
type = "required"
}
)
allowNewTimeProposals = $true
isOnlineMeeting = $true
onlineMeetingProvider = "teamsForBusiness"
}
# A UPN can also be used as -UserId.
New-MgBetaUserEvent -UserId $userId -BodyParameter $params
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.events.events_request_builder import EventsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
from msgraph_beta.generated.models.event import Event
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.body_type import BodyType
from msgraph_beta.generated.models.date_time_time_zone import DateTimeTimeZone
from msgraph_beta.generated.models.location import Location
from msgraph_beta.generated.models.attendee import Attendee
from msgraph_beta.generated.models.email_address import EmailAddress
from msgraph_beta.generated.models.attendee_type import AttendeeType
from msgraph_beta.generated.models.online_meeting_provider_type import OnlineMeetingProviderType
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Event(
subject = "Let's go for lunch",
body = ItemBody(
content_type = BodyType.Html,
content = "Does noon work for you?",
),
start = DateTimeTimeZone(
date_time = "2017-04-15T12:00:00",
time_zone = "Pacific Standard Time",
),
end = DateTimeTimeZone(
date_time = "2017-04-15T14:00:00",
time_zone = "Pacific Standard Time",
),
location = Location(
display_name = "Harry's Bar",
),
attendees = [
Attendee(
email_address = EmailAddress(
address = "samanthab@contoso.com",
name = "Samantha Booth",
),
type = AttendeeType.Required,
),
],
allow_new_time_proposals = True,
is_online_meeting = True,
online_meeting_provider = OnlineMeetingProviderType.TeamsForBusiness,
)
request_configuration = RequestConfiguration()
request_configuration.headers.add("Prefer", "outlook.timezone=\"Pacific Standard Time\"")
result = await graph_client.me.events.post(request_body, request_configuration = request_configuration)
Importante
Los SDK de Microsoft Graph usan la versión v1.0 de la API de manera predeterminada y no admiten todos los tipos, propiedades y API disponibles en la versión beta. Para obtener más información sobre cómo acceder a la API beta con el SDK, consulte Uso de los SDK de Microsoft Graph con la API beta.
En el ejemplo siguiente se muestra la respuesta que muestra cómo las propiedades start y end usan la zona horaria especificada en el Prefer: outlook.timezone encabezado.
Nota: Se puede acortar el objeto de respuesta que se muestra aquí para mejorar la legibilidad.