Espacio de nombres: microsoft.graph
Actualizar las propiedades de un objeto workPlanOccurrence en el plan de trabajo de un usuario. Las novedades requieren que se proporcione el objeto de ocurrencia completo (semántica PUT). PATCH no es compatible.
Esta API está disponible en las siguientes implementaciones en la nube nacional.
| Servicio global |
Administración pública de EE. UU. |
Gobierno de EE. UU. L5 (DOD) |
China operado por 21Vianet |
| ✅ |
❌ |
❌ |
❌ |
Permissions
Elija el permiso o los permisos marcados como con privilegios mínimos para esta API. Use uno o varios permisos con privilegios más altos 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) |
No admitida. |
No admitida. |
| Aplicación |
No admitida. |
No admitida. |
Nota: Los permisos de aplicación solo se admiten cuando se usa el punto de /users/{id} conexión.
Solicitud HTTP
PUT /me/settings/workHoursAndLocations/occurrences/{id}
Nota:
Para llamar al punto de conexión /me, se requiere un usuario con la sesión iniciada y, por lo tanto, un permiso delegado. Los permisos de aplicación no se admiten al usar el /me punto de conexión.
Al usar permisos delegados con el punto de /users/{id} conexión, el identificador debe ser el identificador del usuario que ha iniciado sesión.
PUT /users/{id | userPrincipalName}/settings/workHoursAndLocations/occurrences/{id}
| Nombre |
Descripción |
| Authorization |
{token} de portador. Obligatorio. Obtenga más información sobre autenticación y autorización. |
| Content-Type |
application/json. Obligatorio. |
Cuerpo de la solicitud
En el cuerpo de la solicitud, proporcione una representación JSON de un objeto workPlanOccurrence .
Respuesta
Si se realiza correctamente, este método devuelve un 200 OK código de respuesta y un objeto workPlanOccurrence actualizado en el cuerpo de la respuesta.
Ejemplos
Solicitud
En el ejemplo siguiente se muestra la solicitud.
PUT https://graph.microsoft.com/v1.0/me/settings/workHoursAndLocations/occurrences/QAAuAAAAAB2EAxGqZhHNm8gAqgAvxFoNAOtpUxZW-2ZHr9tjSZTO0jMAA2iQN2IAABA=
Content-type: application/json
{
"start": {
"dateTime": "2025-12-15T08:00:00.0000000",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2025-12-15T12:00:00.0000000",
"timeZone": "Pacific Standard Time"
},
"workLocationType": "timeOff",
"timeOffDetails": {
"subject": "Doctor Appointment",
"isAllDay": false
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new WorkPlanOccurrence
{
Start = new DateTimeTimeZone
{
DateTime = "2025-12-15T08:00:00.0000000",
TimeZone = "Pacific Standard Time",
},
End = new DateTimeTimeZone
{
DateTime = "2025-12-15T12:00:00.0000000",
TimeZone = "Pacific Standard Time",
},
WorkLocationType = WorkLocationType.TimeOff,
TimeOffDetails = new TimeOffDetails
{
Subject = "Doctor Appointment",
IsAllDay = false,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Settings.WorkHoursAndLocations.Occurrences["{workPlanOccurrence-id}"].PutAsync(requestBody);
Para obtener más información sobre cómo agregar el SDK al proyecto y crear una instancia de authProvider, consulte la documentación del SDK.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewWorkPlanOccurrence()
start := graphmodels.NewDateTimeTimeZone()
dateTime := "2025-12-15T08:00:00.0000000"
start.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
start.SetTimeZone(&timeZone)
requestBody.SetStart(start)
end := graphmodels.NewDateTimeTimeZone()
dateTime := "2025-12-15T12:00:00.0000000"
end.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
end.SetTimeZone(&timeZone)
requestBody.SetEnd(end)
workLocationType := graphmodels.TIMEOFF_WORKLOCATIONTYPE
requestBody.SetWorkLocationType(&workLocationType)
timeOffDetails := graphmodels.NewTimeOffDetails()
subject := "Doctor Appointment"
timeOffDetails.SetSubject(&subject)
isAllDay := false
timeOffDetails.SetIsAllDay(&isAllDay)
requestBody.SetTimeOffDetails(timeOffDetails)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
occurrences, err := graphClient.Me().Settings().WorkHoursAndLocations().Occurrences().ByWorkPlanOccurrenceId("workPlanOccurrence-id").Put(context.Background(), requestBody, nil)
Para obtener más información sobre cómo agregar el SDK al proyecto y crear una instancia de authProvider, consulte la documentación del SDK.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
WorkPlanOccurrence workPlanOccurrence = new WorkPlanOccurrence();
DateTimeTimeZone start = new DateTimeTimeZone();
start.setDateTime("2025-12-15T08:00:00.0000000");
start.setTimeZone("Pacific Standard Time");
workPlanOccurrence.setStart(start);
DateTimeTimeZone end = new DateTimeTimeZone();
end.setDateTime("2025-12-15T12:00:00.0000000");
end.setTimeZone("Pacific Standard Time");
workPlanOccurrence.setEnd(end);
workPlanOccurrence.setWorkLocationType(WorkLocationType.TimeOff);
TimeOffDetails timeOffDetails = new TimeOffDetails();
timeOffDetails.setSubject("Doctor Appointment");
timeOffDetails.setIsAllDay(false);
workPlanOccurrence.setTimeOffDetails(timeOffDetails);
WorkPlanOccurrence result = graphClient.me().settings().workHoursAndLocations().occurrences().byWorkPlanOccurrenceId("{workPlanOccurrence-id}").put(workPlanOccurrence);
Para obtener más información sobre cómo agregar el SDK al proyecto y crear una instancia de authProvider, consulte la documentación del SDK.
const options = {
authProvider,
};
const client = Client.init(options);
const workPlanOccurrence = {
start: {
dateTime: '2025-12-15T08:00:00.0000000',
timeZone: 'Pacific Standard Time'
},
end: {
dateTime: '2025-12-15T12:00:00.0000000',
timeZone: 'Pacific Standard Time'
},
workLocationType: 'timeOff',
timeOffDetails: {
subject: 'Doctor Appointment',
isAllDay: false
}
};
await client.api('/me/settings/workHoursAndLocations/occurrences/QAAuAAAAAB2EAxGqZhHNm8gAqgAvxFoNAOtpUxZW-2ZHr9tjSZTO0jMAA2iQN2IAABA=')
.put(workPlanOccurrence);
Para obtener más información sobre cómo agregar el SDK al proyecto y crear una instancia de authProvider, consulte la documentación del SDK.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\WorkPlanOccurrence;
use Microsoft\Graph\Generated\Models\DateTimeTimeZone;
use Microsoft\Graph\Generated\Models\WorkLocationType;
use Microsoft\Graph\Generated\Models\TimeOffDetails;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new WorkPlanOccurrence();
$start = new DateTimeTimeZone();
$start->setDateTime('2025-12-15T08:00:00.0000000');
$start->setTimeZone('Pacific Standard Time');
$requestBody->setStart($start);
$end = new DateTimeTimeZone();
$end->setDateTime('2025-12-15T12:00:00.0000000');
$end->setTimeZone('Pacific Standard Time');
$requestBody->setEnd($end);
$requestBody->setWorkLocationType(new WorkLocationType('timeOff'));
$timeOffDetails = new TimeOffDetails();
$timeOffDetails->setSubject('Doctor Appointment');
$timeOffDetails->setIsAllDay(false);
$requestBody->setTimeOffDetails($timeOffDetails);
$result = $graphServiceClient->me()->settings()->workHoursAndLocations()->occurrences()->byWorkPlanOccurrenceId('workPlanOccurrence-id')->put($requestBody)->wait();
Para obtener más información sobre cómo agregar el SDK al proyecto y crear una instancia de authProvider, consulte la documentación del SDK.
Import-Module Microsoft.Graph.Users
$params = @{
start = @{
dateTime = "2025-12-15T08:00:00.0000000"
timeZone = "Pacific Standard Time"
}
end = @{
dateTime = "2025-12-15T12:00:00.0000000"
timeZone = "Pacific Standard Time"
}
workLocationType = "timeOff"
timeOffDetails = @{
subject = "Doctor Appointment"
isAllDay = $false
}
}
# A UPN can also be used as -UserId.
Set-MgUserSettingWorkHourAndLocationOccurrence -UserId $userId -WorkPlanOccurrenceId $workPlanOccurrenceId -BodyParameter $params
Para obtener más información sobre cómo agregar el SDK al proyecto y crear una instancia de authProvider, consulte la documentación del SDK.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.work_plan_occurrence import WorkPlanOccurrence
from msgraph.generated.models.date_time_time_zone import DateTimeTimeZone
from msgraph.generated.models.work_location_type import WorkLocationType
from msgraph.generated.models.time_off_details import TimeOffDetails
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = WorkPlanOccurrence(
start = DateTimeTimeZone(
date_time = "2025-12-15T08:00:00.0000000",
time_zone = "Pacific Standard Time",
),
end = DateTimeTimeZone(
date_time = "2025-12-15T12:00:00.0000000",
time_zone = "Pacific Standard Time",
),
work_location_type = WorkLocationType.TimeOff,
time_off_details = TimeOffDetails(
subject = "Doctor Appointment",
is_all_day = False,
),
)
result = await graph_client.me.settings.work_hours_and_locations.occurrences.by_work_plan_occurrence_id('workPlanOccurrence-id').put(request_body)
Para obtener más información sobre cómo agregar el SDK al proyecto y crear una instancia de authProvider, consulte la documentación del SDK.
Respuesta
En el ejemplo siguiente se muestra la respuesta.
Nota: Se puede acortar el objeto de respuesta que se muestra aquí para mejorar la legibilidad.
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "AAMkAGVmMDEzMTM4LTZmYWUtNDdkNC1hMDZiLTU1OGY5OTZhYmY4OABGAAAAAAAiQ8W967B7TKBjgx9rVEURBwAiIsqMbYjsT5e-T7KzowPTAAAAAAENAAAiIsqMbYjsT5e-T7KzowPTAAABvv6cAAA=",
"recurrenceId": null,
"start": {
"dateTime": "2025-12-15T08:00:00.0000000",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2025-12-15T12:00:00.0000000",
"timeZone": "Pacific Standard Time"
},
"workLocationType": "timeOff",
"timeOffDetails": {
"subject": "Doctor Appointment",
"isAllDay": false
}
}