Espace de noms: microsoft.graph
Importante
Les API sous la version /beta dans Microsoft Graph sont susceptibles d’être modifiées. L’utilisation de ces API dans des applications de production n’est pas prise en charge. Pour déterminer si une API est disponible dans v1.0, utilisez le sélecteur Version .
Mettez à jour les propriétés d’un objet workPlanRecurrence dans votre propre plan de travail. Mises à jour exiger que l’objet de périodicité complet soit fourni (sémantique PUT). PATCH n’est pas pris en charge.
Cette API est disponible dans les déploiements de cloud national suivants.
| Service global |
Gouvernement des États-Unis L4 |
Us Government L5 (DOD) |
Chine gérée par 21Vianet |
| ✅ |
❌ |
❌ |
❌ |
Autorisations
Choisissez l’autorisation ou les autorisations marquées comme moins privilégiées pour cette API. Utilisez une autorisation ou des autorisations privilégiées plus élevées uniquement si votre application en a besoin. Pour plus d’informations sur les autorisations déléguées et d’application, consultez Types d’autorisations. Pour en savoir plus sur ces autorisations, consultez les informations de référence sur les autorisations.
| Type d’autorisation |
Autorisations avec privilèges minimum |
Autorisations privilégiées plus élevées |
| Déléguée (compte professionnel ou scolaire) |
Calendars.ReadWrite |
Non disponible. |
| Déléguée (compte Microsoft personnel) |
Non prise en charge. |
Non prise en charge. |
| Application |
Non prise en charge. |
Non prise en charge. |
Requête HTTP
PUT /me/settings/workHoursAndLocations/recurrences/{id}
Remarque
L’appel du point de terminaison /me nécessite un utilisateur connecté et par conséquent une autorisation déléguée. Les autorisations d’application ne sont pas prises en charge lors de l’utilisation du point de /me terminaison.
Lorsque vous utilisez le point de /users/{id} terminaison, l’ID doit être votre propre ID d’utilisateur.
PUT /users/{id | userPrincipalName}/settings/workHoursAndLocations/recurrences/{id}
Corps de la demande
Dans le corps de la demande, fournissez une représentation JSON d’un objet workPlanRecurrence .
Réponse
Si elle réussit, cette méthode renvoie un 200 OK code de réponse et un objet workPlanRecurrence mis à jour dans le corps de la réponse.
Exemples
Demande
L’exemple suivant illustre une demande.
PUT https://graph.microsoft.com/beta/me/settings/workHoursAndLocations/recurrences/AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0A62lTFlb-Zkev22NJlM7SMwADaJA3YgAA
Content-type: application/json
{
"start": {
"dateTime": "2025-12-11T09:00:00.0000000",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2025-12-11T18:00:00.0000000",
"timeZone": "Pacific Standard Time"
},
"workLocationType": "office",
"recurrence": {
"pattern": {
"type": "weekly",
"interval": 1,
"firstDayOfWeek": "sunday",
"daysOfWeek": ["thursday"]
},
"range": {
"type": "noEnd",
"startDate": "2025-12-11",
"recurrenceTimeZone": "Pacific Standard Time"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new WorkPlanRecurrence
{
Start = new DateTimeTimeZone
{
DateTime = "2025-12-11T09:00:00.0000000",
TimeZone = "Pacific Standard Time",
},
End = new DateTimeTimeZone
{
DateTime = "2025-12-11T18:00:00.0000000",
TimeZone = "Pacific Standard Time",
},
WorkLocationType = WorkLocationType.Office,
Recurrence = new PatternedRecurrence
{
Pattern = new RecurrencePattern
{
Type = RecurrencePatternType.Weekly,
Interval = 1,
FirstDayOfWeek = DayOfWeekObject.Sunday,
DaysOfWeek = new List<DayOfWeekObject?>
{
DayOfWeekObject.Thursday,
},
},
Range = new RecurrenceRange
{
Type = RecurrenceRangeType.NoEnd,
StartDate = new Date(DateTime.Parse("2025-12-11")),
RecurrenceTimeZone = "Pacific Standard Time",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Settings.WorkHoursAndLocations.Recurrences["{workPlanRecurrence-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.NewWorkPlanRecurrence()
start := graphmodels.NewDateTimeTimeZone()
dateTime := "2025-12-11T09:00:00.0000000"
start.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
start.SetTimeZone(&timeZone)
requestBody.SetStart(start)
end := graphmodels.NewDateTimeTimeZone()
dateTime := "2025-12-11T18:00:00.0000000"
end.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
end.SetTimeZone(&timeZone)
requestBody.SetEnd(end)
workLocationType := graphmodels.OFFICE_WORKLOCATIONTYPE
requestBody.SetWorkLocationType(&workLocationType)
recurrence := graphmodels.NewPatternedRecurrence()
pattern := graphmodels.NewRecurrencePattern()
type := graphmodels.WEEKLY_RECURRENCEPATTERNTYPE
pattern.SetType(&type)
interval := int32(1)
pattern.SetInterval(&interval)
firstDayOfWeek := graphmodels.SUNDAY_DAYOFWEEK
pattern.SetFirstDayOfWeek(&firstDayOfWeek)
daysOfWeek := []graphmodels.DayOfWeekable {
dayOfWeek := graphmodels.THURSDAY_DAYOFWEEK
pattern.SetDayOfWeek(&dayOfWeek)
}
pattern.SetDaysOfWeek(daysOfWeek)
recurrence.SetPattern(pattern)
range := graphmodels.NewRecurrenceRange()
type := graphmodels.NOEND_RECURRENCERANGETYPE
range.SetType(&type)
startDate := 2025-12-11
range.SetStartDate(&startDate)
recurrenceTimeZone := "Pacific Standard Time"
range.SetRecurrenceTimeZone(&recurrenceTimeZone)
recurrence.SetRange(range)
requestBody.SetRecurrence(recurrence)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
recurrences, err := graphClient.Me().Settings().WorkHoursAndLocations().Recurrences().ByWorkPlanRecurrenceId("workPlanRecurrence-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);
WorkPlanRecurrence workPlanRecurrence = new WorkPlanRecurrence();
DateTimeTimeZone start = new DateTimeTimeZone();
start.setDateTime("2025-12-11T09:00:00.0000000");
start.setTimeZone("Pacific Standard Time");
workPlanRecurrence.setStart(start);
DateTimeTimeZone end = new DateTimeTimeZone();
end.setDateTime("2025-12-11T18:00:00.0000000");
end.setTimeZone("Pacific Standard Time");
workPlanRecurrence.setEnd(end);
workPlanRecurrence.setWorkLocationType(WorkLocationType.Office);
PatternedRecurrence recurrence = new PatternedRecurrence();
RecurrencePattern pattern = new RecurrencePattern();
pattern.setType(RecurrencePatternType.Weekly);
pattern.setInterval(1);
pattern.setFirstDayOfWeek(DayOfWeek.Sunday);
LinkedList<DayOfWeek> daysOfWeek = new LinkedList<DayOfWeek>();
daysOfWeek.add(DayOfWeek.Thursday);
pattern.setDaysOfWeek(daysOfWeek);
recurrence.setPattern(pattern);
RecurrenceRange range = new RecurrenceRange();
range.setType(RecurrenceRangeType.NoEnd);
LocalDate startDate = LocalDate.parse("2025-12-11");
range.setStartDate(startDate);
range.setRecurrenceTimeZone("Pacific Standard Time");
recurrence.setRange(range);
workPlanRecurrence.setRecurrence(recurrence);
WorkPlanRecurrence result = graphClient.me().settings().workHoursAndLocations().recurrences().byWorkPlanRecurrenceId("{workPlanRecurrence-id}").put(workPlanRecurrence);
const options = {
authProvider,
};
const client = Client.init(options);
const workPlanRecurrence = {
start: {
dateTime: '2025-12-11T09:00:00.0000000',
timeZone: 'Pacific Standard Time'
},
end: {
dateTime: '2025-12-11T18:00:00.0000000',
timeZone: 'Pacific Standard Time'
},
workLocationType: 'office',
recurrence: {
pattern: {
type: 'weekly',
interval: 1,
firstDayOfWeek: 'sunday',
daysOfWeek: ['thursday']
},
range: {
type: 'noEnd',
startDate: '2025-12-11',
recurrenceTimeZone: 'Pacific Standard Time'
}
}
};
await client.api('/me/settings/workHoursAndLocations/recurrences/AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0A62lTFlb-Zkev22NJlM7SMwADaJA3YgAA')
.version('beta')
.put(workPlanRecurrence);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\WorkPlanRecurrence;
use Microsoft\Graph\Beta\Generated\Models\DateTimeTimeZone;
use Microsoft\Graph\Beta\Generated\Models\WorkLocationType;
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;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new WorkPlanRecurrence();
$start = new DateTimeTimeZone();
$start->setDateTime('2025-12-11T09:00:00.0000000');
$start->setTimeZone('Pacific Standard Time');
$requestBody->setStart($start);
$end = new DateTimeTimeZone();
$end->setDateTime('2025-12-11T18:00:00.0000000');
$end->setTimeZone('Pacific Standard Time');
$requestBody->setEnd($end);
$requestBody->setWorkLocationType(new WorkLocationType('office'));
$recurrence = new PatternedRecurrence();
$recurrencePattern = new RecurrencePattern();
$recurrencePattern->setType(new RecurrencePatternType('weekly'));
$recurrencePattern->setInterval(1);
$recurrencePattern->setFirstDayOfWeek(new DayOfWeek('sunday'));
$recurrencePattern->setDaysOfWeek([new DayOfWeek('thursday'), ]);
$recurrence->setPattern($recurrencePattern);
$recurrenceRange = new RecurrenceRange();
$recurrenceRange->setType(new RecurrenceRangeType('noEnd'));
$recurrenceRange->setStartDate(new Date('2025-12-11'));
$recurrenceRange->setRecurrenceTimeZone('Pacific Standard Time');
$recurrence->setRange($recurrenceRange);
$requestBody->setRecurrence($recurrence);
$result = $graphServiceClient->me()->settings()->workHoursAndLocations()->recurrences()->byWorkPlanRecurrenceId('workPlanRecurrence-id')->put($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Users
$params = @{
start = @{
dateTime = "2025-12-11T09:00:00.0000000"
timeZone = "Pacific Standard Time"
}
end = @{
dateTime = "2025-12-11T18:00:00.0000000"
timeZone = "Pacific Standard Time"
}
workLocationType = "office"
recurrence = @{
pattern = @{
type = "weekly"
interval = 1
firstDayOfWeek = "sunday"
daysOfWeek = @(
"thursday"
)
}
range = @{
type = "noEnd"
startDate = "2025-12-11"
recurrenceTimeZone = "Pacific Standard Time"
}
}
}
# A UPN can also be used as -UserId.
Set-MgBetaUserSettingWorkHourAndLocationRecurrence -UserId $userId -WorkPlanRecurrenceId $workPlanRecurrenceId -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_recurrence import WorkPlanRecurrence
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.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
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = WorkPlanRecurrence(
start = DateTimeTimeZone(
date_time = "2025-12-11T09:00:00.0000000",
time_zone = "Pacific Standard Time",
),
end = DateTimeTimeZone(
date_time = "2025-12-11T18:00:00.0000000",
time_zone = "Pacific Standard Time",
),
work_location_type = WorkLocationType.Office,
recurrence = PatternedRecurrence(
pattern = RecurrencePattern(
type = RecurrencePatternType.Weekly,
interval = 1,
first_day_of_week = DayOfWeek.Sunday,
days_of_week = [
DayOfWeek.Thursday,
],
),
range = RecurrenceRange(
type = RecurrenceRangeType.NoEnd,
start_date = "2025-12-11",
recurrence_time_zone = "Pacific Standard Time",
),
),
)
result = await graph_client.me.settings.work_hours_and_locations.recurrences.by_work_plan_recurrence_id('workPlanRecurrence-id').put(request_body)
Réponse
L’exemple suivant illustre la réponse.
Remarque : l’objet de réponse affiché ci-après peut être raccourci pour plus de lisibilité.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#users('15b9b296-dac5-43d0-8b94-93bb67eef619')/settings/workHoursAndLocations/recurrences/$entity",
"id": "AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0A62lTFlb-Zkev22NJlM7SMwADxDWWKgAA",
"workLocationType": "office",
"placeId": null,
"start": {
"dateTime": "2025-12-11T09:00:00.0000000",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2025-12-11T18:00:00.0000000",
"timeZone": "Pacific Standard Time"
},
"recurrence": {
"pattern": {
"type": "weekly",
"interval": 1,
"firstDayOfWeek": "sunday",
"daysOfWeek": [
"thursday"
],
"month": 0,
"dayOfMonth": 0,
"index": "first"
},
"range": {
"type": "noEnd",
"startDate": "2025-12-11",
"endDate": null,
"recurrenceTimeZone": "Pacific Standard Time",
"numberOfOccurrences": 0
}
}
}