Namespace: microsoft.graph
Wichtig
Die APIs unter der /beta Version in Microsoft Graph können sich ändern. Die Verwendung dieser APIs in Produktionsanwendungen wird nicht unterstützt. Um festzustellen, ob eine API in v1.0 verfügbar ist, verwenden Sie die Version Selektor.
Aktualisieren Sie die Eigenschaften eines workPlanOccurrence-Objekts in Ihrem eigenen Arbeitsplan. Updates erfordern, dass das vollständige Vorkommnisobjekt bereitgestellt wird (PUT-Semantik). PATCH wird nicht unterstützt.
Diese API ist in den folgenden nationalen Cloudbereitstellungen verfügbar.
| Weltweiter Service |
US Government L4 |
US Government L5 (DOD) |
China, betrieben von 21Vianet |
| ✅ |
❌ |
❌ |
❌ |
Berechtigungen
Wählen Sie die Berechtigungen aus, die für diese API als am wenigsten privilegiert markiert sind. Verwenden Sie eine höhere Berechtigung oder Berechtigungen nur, wenn Ihre App dies erfordert. Ausführliche Informationen zu delegierten Berechtigungen und Anwendungsberechtigungen finden Sie unter Berechtigungstypen. Weitere Informationen zu diesen Berechtigungen finden Sie in der Berechtigungsreferenz.
| Berechtigungstyp |
Berechtigungen mit den geringsten Berechtigungen |
Berechtigungen mit höheren Berechtigungen |
| Delegiert (Geschäfts-, Schul- oder Unikonto) |
Calendars.ReadWrite |
Nicht verfügbar. |
| Delegiert (persönliches Microsoft-Konto) |
Nicht unterstützt |
Nicht unterstützt |
| Application |
Nicht unterstützt |
Nicht unterstützt |
HTTP-Anforderung
PUT /me/settings/workHoursAndLocations/occurrences/{id}
Hinweis
Das Aufrufen des /me-Endpunkts erfordert einen angemeldeten Benutzer und daher eine delegierte Berechtigung. Anwendungsberechtigungen werden bei Verwendung des /me Endpunkts nicht unterstützt.
Wenn Sie den /users/{id} Endpunkt verwenden, muss die ID Ihre eigene Benutzer-ID sein.
PUT /users/{id | userPrincipalName}/settings/workHoursAndLocations/occurrences/{id}
Anforderungstext
Geben Sie im Anforderungstext eine JSON-Darstellung eines workPlanOccurrence-Objekts an .
Antwort
Bei erfolgreicher Ausführung gibt die Methode den 200 OK Antwortcode und ein aktualisiertes workPlanOccurrence-Objekt im Antworttext zurück.
Beispiele
Anforderung
Das folgende Beispiel zeigt eine Anfrage.
PUT https://graph.microsoft.com/beta/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.Beta.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);
// 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.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)
// 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);
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=')
.version('beta')
.put(workPlanOccurrence);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\WorkPlanOccurrence;
use Microsoft\Graph\Beta\Generated\Models\DateTimeTimeZone;
use Microsoft\Graph\Beta\Generated\Models\WorkLocationType;
use Microsoft\Graph\Beta\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();
Import-Module Microsoft.Graph.Beta.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-MgBetaUserSettingWorkHourAndLocationOccurrence -UserId $userId -WorkPlanOccurrenceId $workPlanOccurrenceId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.work_plan_occurrence import WorkPlanOccurrence
from msgraph_beta.generated.models.date_time_time_zone import DateTimeTimeZone
from msgraph_beta.generated.models.work_location_type import WorkLocationType
from msgraph_beta.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)
Antwort
Das folgende Beispiel zeigt die Antwort.
Hinweis: Das hier gezeigte Antwortobjekt kann zur besseren Lesbarkeit gekürzt werden.
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
}
}