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 .
Créez un instance timeOff dans une planification.
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.
Cette API prend en charge les autorisations d’administrateur. Les utilisateurs disposant de rôles d’administrateur peuvent accéder aux équipes dont ils ne sont pas membres.
| Type d’autorisation |
Autorisations avec privilèges minimum |
Autorisations privilégiées plus élevées |
| Déléguée (compte professionnel ou scolaire) |
Schedule.ReadWrite.All |
Group.ReadWrite.All |
| Déléguée (compte Microsoft personnel) |
Non prise en charge. |
Non prise en charge. |
| Application |
Schedule.ReadWrite.All |
Non disponible. |
Requête HTTP
POST /teams/{teamId}/schedule/timesOff
| En-tête |
Valeur |
| Autorisation |
Porteur {token}. Obligatoire. En savoir plus sur l’authentification et l’autorisation. |
| Content-Type |
application/json. Obligatoire. |
| MS-APP-ACTS-AS (déconseillé) |
UN ID d’utilisateur (GUID). Obligatoire uniquement si le jeton d’autorisation est un jeton d’application ; sinon, facultatif. L’en-tête MS-APP-ACTS-AS est déconseillé et n’est plus nécessaire avec les jetons d’application. |
Réponse
Si elle réussit, cette méthode renvoie un 201 Created code de réponse et un objet timeOff dans le corps de la réponse.
Exemple
Demande
L’exemple suivant illustre une demande.
POST https://graph.microsoft.com/beta/teams/{teamId}/schedule/timesOff
Content-type: application/json
{
"userId": "c5d0c76b-80c4-481c-be50-923cd8d680a1",
"sharedTimeOff": {
"timeOffReasonId": "TOR_891045ca-b5d2-406b-aa06-a3c8921245d7",
"startDateTime": "2019-03-11T07:00:00Z",
"endDateTime": "2019-03-12T07:00:00Z",
"theme": "white"
},
"draftTimeOff": {
"timeOffReasonId": "TOR_891045ca-b5d2-406b-aa06-a3c8921245d7",
"startDateTime": "2019-03-11T07:00:00Z",
"endDateTime": "2019-03-12T07:00:00Z",
"theme": "pink"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new TimeOff
{
UserId = "c5d0c76b-80c4-481c-be50-923cd8d680a1",
SharedTimeOff = new TimeOffItem
{
TimeOffReasonId = "TOR_891045ca-b5d2-406b-aa06-a3c8921245d7",
StartDateTime = DateTimeOffset.Parse("2019-03-11T07:00:00Z"),
EndDateTime = DateTimeOffset.Parse("2019-03-12T07:00:00Z"),
Theme = ScheduleEntityTheme.White,
},
DraftTimeOff = new TimeOffItem
{
TimeOffReasonId = "TOR_891045ca-b5d2-406b-aa06-a3c8921245d7",
StartDateTime = DateTimeOffset.Parse("2019-03-11T07:00:00Z"),
EndDateTime = DateTimeOffset.Parse("2019-03-12T07:00:00Z"),
Theme = ScheduleEntityTheme.Pink,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Teams["{team-id}"].Schedule.TimesOff.PostAsync(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.NewTimeOff()
userId := "c5d0c76b-80c4-481c-be50-923cd8d680a1"
requestBody.SetUserId(&userId)
sharedTimeOff := graphmodels.NewTimeOffItem()
timeOffReasonId := "TOR_891045ca-b5d2-406b-aa06-a3c8921245d7"
sharedTimeOff.SetTimeOffReasonId(&timeOffReasonId)
startDateTime , err := time.Parse(time.RFC3339, "2019-03-11T07:00:00Z")
sharedTimeOff.SetStartDateTime(&startDateTime)
endDateTime , err := time.Parse(time.RFC3339, "2019-03-12T07:00:00Z")
sharedTimeOff.SetEndDateTime(&endDateTime)
theme := graphmodels.WHITE_SCHEDULEENTITYTHEME
sharedTimeOff.SetTheme(&theme)
requestBody.SetSharedTimeOff(sharedTimeOff)
draftTimeOff := graphmodels.NewTimeOffItem()
timeOffReasonId := "TOR_891045ca-b5d2-406b-aa06-a3c8921245d7"
draftTimeOff.SetTimeOffReasonId(&timeOffReasonId)
startDateTime , err := time.Parse(time.RFC3339, "2019-03-11T07:00:00Z")
draftTimeOff.SetStartDateTime(&startDateTime)
endDateTime , err := time.Parse(time.RFC3339, "2019-03-12T07:00:00Z")
draftTimeOff.SetEndDateTime(&endDateTime)
theme := graphmodels.PINK_SCHEDULEENTITYTHEME
draftTimeOff.SetTheme(&theme)
requestBody.SetDraftTimeOff(draftTimeOff)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
timesOff, err := graphClient.Teams().ByTeamId("team-id").Schedule().TimesOff().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
TimeOff timeOff = new TimeOff();
timeOff.setUserId("c5d0c76b-80c4-481c-be50-923cd8d680a1");
TimeOffItem sharedTimeOff = new TimeOffItem();
sharedTimeOff.setTimeOffReasonId("TOR_891045ca-b5d2-406b-aa06-a3c8921245d7");
OffsetDateTime startDateTime = OffsetDateTime.parse("2019-03-11T07:00:00Z");
sharedTimeOff.setStartDateTime(startDateTime);
OffsetDateTime endDateTime = OffsetDateTime.parse("2019-03-12T07:00:00Z");
sharedTimeOff.setEndDateTime(endDateTime);
sharedTimeOff.setTheme(ScheduleEntityTheme.White);
timeOff.setSharedTimeOff(sharedTimeOff);
TimeOffItem draftTimeOff = new TimeOffItem();
draftTimeOff.setTimeOffReasonId("TOR_891045ca-b5d2-406b-aa06-a3c8921245d7");
OffsetDateTime startDateTime1 = OffsetDateTime.parse("2019-03-11T07:00:00Z");
draftTimeOff.setStartDateTime(startDateTime1);
OffsetDateTime endDateTime1 = OffsetDateTime.parse("2019-03-12T07:00:00Z");
draftTimeOff.setEndDateTime(endDateTime1);
draftTimeOff.setTheme(ScheduleEntityTheme.Pink);
timeOff.setDraftTimeOff(draftTimeOff);
TimeOff result = graphClient.teams().byTeamId("{team-id}").schedule().timesOff().post(timeOff);
const options = {
authProvider,
};
const client = Client.init(options);
const timeOff = {
userId: 'c5d0c76b-80c4-481c-be50-923cd8d680a1',
sharedTimeOff: {
timeOffReasonId: 'TOR_891045ca-b5d2-406b-aa06-a3c8921245d7',
startDateTime: '2019-03-11T07:00:00Z',
endDateTime: '2019-03-12T07:00:00Z',
theme: 'white'
},
draftTimeOff: {
timeOffReasonId: 'TOR_891045ca-b5d2-406b-aa06-a3c8921245d7',
startDateTime: '2019-03-11T07:00:00Z',
endDateTime: '2019-03-12T07:00:00Z',
theme: 'pink'
}
};
await client.api('/teams/{teamId}/schedule/timesOff')
.version('beta')
.post(timeOff);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\TimeOff;
use Microsoft\Graph\Beta\Generated\Models\TimeOffItem;
use Microsoft\Graph\Beta\Generated\Models\ScheduleEntityTheme;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new TimeOff();
$requestBody->setUserId('c5d0c76b-80c4-481c-be50-923cd8d680a1');
$sharedTimeOff = new TimeOffItem();
$sharedTimeOff->setTimeOffReasonId('TOR_891045ca-b5d2-406b-aa06-a3c8921245d7');
$sharedTimeOff->setStartDateTime(new \DateTime('2019-03-11T07:00:00Z'));
$sharedTimeOff->setEndDateTime(new \DateTime('2019-03-12T07:00:00Z'));
$sharedTimeOff->setTheme(new ScheduleEntityTheme('white'));
$requestBody->setSharedTimeOff($sharedTimeOff);
$draftTimeOff = new TimeOffItem();
$draftTimeOff->setTimeOffReasonId('TOR_891045ca-b5d2-406b-aa06-a3c8921245d7');
$draftTimeOff->setStartDateTime(new \DateTime('2019-03-11T07:00:00Z'));
$draftTimeOff->setEndDateTime(new \DateTime('2019-03-12T07:00:00Z'));
$draftTimeOff->setTheme(new ScheduleEntityTheme('pink'));
$requestBody->setDraftTimeOff($draftTimeOff);
$result = $graphServiceClient->teams()->byTeamId('team-id')->schedule()->timesOff()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Teams
$params = @{
userId = "c5d0c76b-80c4-481c-be50-923cd8d680a1"
sharedTimeOff = @{
timeOffReasonId = "TOR_891045ca-b5d2-406b-aa06-a3c8921245d7"
startDateTime = [System.DateTime]::Parse("2019-03-11T07:00:00Z")
endDateTime = [System.DateTime]::Parse("2019-03-12T07:00:00Z")
theme = "white"
}
draftTimeOff = @{
timeOffReasonId = "TOR_891045ca-b5d2-406b-aa06-a3c8921245d7"
startDateTime = [System.DateTime]::Parse("2019-03-11T07:00:00Z")
endDateTime = [System.DateTime]::Parse("2019-03-12T07:00:00Z")
theme = "pink"
}
}
New-MgBetaTeamScheduleTimeOff -TeamId $teamId -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.time_off import TimeOff
from msgraph_beta.generated.models.time_off_item import TimeOffItem
from msgraph_beta.generated.models.schedule_entity_theme import ScheduleEntityTheme
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = TimeOff(
user_id = "c5d0c76b-80c4-481c-be50-923cd8d680a1",
shared_time_off = TimeOffItem(
time_off_reason_id = "TOR_891045ca-b5d2-406b-aa06-a3c8921245d7",
start_date_time = "2019-03-11T07:00:00Z",
end_date_time = "2019-03-12T07:00:00Z",
theme = ScheduleEntityTheme.White,
),
draft_time_off = TimeOffItem(
time_off_reason_id = "TOR_891045ca-b5d2-406b-aa06-a3c8921245d7",
start_date_time = "2019-03-11T07:00:00Z",
end_date_time = "2019-03-12T07:00:00Z",
theme = ScheduleEntityTheme.Pink,
),
)
result = await graph_client.teams.by_team_id('team-id').schedule.times_off.post(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 201 Created
Content-type: application/json
{
"userId": "c5d0c76b-80c4-481c-be50-923cd8d680a1",
"createdDateTime": "2019-03-14T05:35:57.755Z",
"lastModifiedDateTime": "2019-03-14T05:36:08.381Z",
"lastModifiedBy": {
"application": null,
"device": null,
"conversation": null,
"user": {
"id": "366c0b19-49b1-41b5-a03f-9f3887bd0ed8",
"displayName": "John Doe"
}
},
"sharedTimeOff": {
"timeOffReasonId": "TOR_891045ca-b5d2-406b-aa06-a3c8921245d7",
"startDateTime": "2019-03-11T07:00:00Z",
"endDateTime": "2019-03-12T07:00:00Z",
"theme": "white"
},
"draftTimeOff": {
"timeOffReasonId": "TOR_891045ca-b5d2-406b-aa06-a3c8921245d7",
"startDateTime": "2019-03-11T07:00:00Z",
"endDateTime": "2019-03-12T07:00:00Z",
"theme": "pink"
}
}