Die Dauer einer Schicht darf nicht kleiner als 1 Minute oder länger als 24 Stunden sein.
Wählen Sie für diese API die Als am wenigsten privilegierten Berechtigungen gekennzeichneten Berechtigungen aus. Verwenden Sie nur dann eine Berechtigung mit höheren Berechtigungen , wenn dies für Ihre App erforderlich ist. Ausführliche Informationen zu delegierten Berechtigungen und Anwendungsberechtigungen finden Sie unter Berechtigungstypen. Weitere Informationen zu diesen Berechtigungen finden Sie in der Berechtigungsreferenz.
Das folgende Beispiel zeigt eine Anfrage.
POST https://graph.microsoft.com/v1.0/teams/{teamId}/schedule/shifts
Content-type: application/json
{
"id": "SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8",
"userId": "c5d0c76b-80c4-481c-be50-923cd8d680a1",
"schedulingGroupId": "TAG_228940ed-ff84-4e25-b129-1b395cf78be0",
"sharedShift": {
"displayName": "Day shift",
"notes": "Please do inventory as part of your shift.",
"startDateTime": "2019-03-11T15:00:00Z",
"endDateTime": "2019-03-12T00:00:00Z",
"theme": "blue",
"activities": [
{
"isPaid": true,
"startDateTime": "2019-03-11T15:00:00Z",
"endDateTime": "2019-03-11T15:15:00Z",
"code": "",
"displayName": "Lunch"
}
]
},
"draftShift": {
"displayName": "Day shift",
"notes": "Please do inventory as part of your shift.",
"startDateTime": "2019-03-11T15:00:00Z",
"endDateTime": "2019-03-12T00:00:00Z",
"theme": "blue",
"activities": [
{
"isPaid": true,
"startDateTime": "2019-03-11T15:00:00Z",
"endDateTime": "2019-03-11T15:30:00Z",
"code": "",
"displayName": "Lunch"
}
]
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Shift
{
Id = "SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8",
UserId = "c5d0c76b-80c4-481c-be50-923cd8d680a1",
SchedulingGroupId = "TAG_228940ed-ff84-4e25-b129-1b395cf78be0",
SharedShift = new ShiftItem
{
DisplayName = "Day shift",
Notes = "Please do inventory as part of your shift.",
StartDateTime = DateTimeOffset.Parse("2019-03-11T15:00:00Z"),
EndDateTime = DateTimeOffset.Parse("2019-03-12T00:00:00Z"),
Theme = ScheduleEntityTheme.Blue,
Activities = new List<ShiftActivity>
{
new ShiftActivity
{
IsPaid = true,
StartDateTime = DateTimeOffset.Parse("2019-03-11T15:00:00Z"),
EndDateTime = DateTimeOffset.Parse("2019-03-11T15:15:00Z"),
Code = "",
DisplayName = "Lunch",
},
},
},
DraftShift = new ShiftItem
{
DisplayName = "Day shift",
Notes = "Please do inventory as part of your shift.",
StartDateTime = DateTimeOffset.Parse("2019-03-11T15:00:00Z"),
EndDateTime = DateTimeOffset.Parse("2019-03-12T00:00:00Z"),
Theme = ScheduleEntityTheme.Blue,
Activities = new List<ShiftActivity>
{
new ShiftActivity
{
IsPaid = true,
StartDateTime = DateTimeOffset.Parse("2019-03-11T15:00:00Z"),
EndDateTime = DateTimeOffset.Parse("2019-03-11T15:30:00Z"),
Code = "",
DisplayName = "Lunch",
},
},
},
};
// 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.Shifts.PostAsync(requestBody);
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
mgc teams schedule shifts create --team-id {team-id} --body '{\
"id": "SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8",\
"userId": "c5d0c76b-80c4-481c-be50-923cd8d680a1",\
"schedulingGroupId": "TAG_228940ed-ff84-4e25-b129-1b395cf78be0",\
"sharedShift": {\
"displayName": "Day shift",\
"notes": "Please do inventory as part of your shift.",\
"startDateTime": "2019-03-11T15:00:00Z",\
"endDateTime": "2019-03-12T00:00:00Z",\
"theme": "blue",\
"activities": [\
{\
"isPaid": true,\
"startDateTime": "2019-03-11T15:00:00Z",\
"endDateTime": "2019-03-11T15:15:00Z",\
"code": "",\
"displayName": "Lunch"\
}\
]\
},\
"draftShift": {\
"displayName": "Day shift",\
"notes": "Please do inventory as part of your shift.",\
"startDateTime": "2019-03-11T15:00:00Z",\
"endDateTime": "2019-03-12T00:00:00Z",\
"theme": "blue",\
"activities": [\
{\
"isPaid": true,\
"startDateTime": "2019-03-11T15:00:00Z",\
"endDateTime": "2019-03-11T15:30:00Z",\
"code": "",\
"displayName": "Lunch"\
}\
]\
}\
}\
'
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
// 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.NewShift()
id := "SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8"
requestBody.SetId(&id)
userId := "c5d0c76b-80c4-481c-be50-923cd8d680a1"
requestBody.SetUserId(&userId)
schedulingGroupId := "TAG_228940ed-ff84-4e25-b129-1b395cf78be0"
requestBody.SetSchedulingGroupId(&schedulingGroupId)
sharedShift := graphmodels.NewShiftItem()
displayName := "Day shift"
sharedShift.SetDisplayName(&displayName)
notes := "Please do inventory as part of your shift."
sharedShift.SetNotes(¬es)
startDateTime , err := time.Parse(time.RFC3339, "2019-03-11T15:00:00Z")
sharedShift.SetStartDateTime(&startDateTime)
endDateTime , err := time.Parse(time.RFC3339, "2019-03-12T00:00:00Z")
sharedShift.SetEndDateTime(&endDateTime)
theme := graphmodels.BLUE_SCHEDULEENTITYTHEME
sharedShift.SetTheme(&theme)
shiftActivity := graphmodels.NewShiftActivity()
isPaid := true
shiftActivity.SetIsPaid(&isPaid)
startDateTime , err := time.Parse(time.RFC3339, "2019-03-11T15:00:00Z")
shiftActivity.SetStartDateTime(&startDateTime)
endDateTime , err := time.Parse(time.RFC3339, "2019-03-11T15:15:00Z")
shiftActivity.SetEndDateTime(&endDateTime)
code := ""
shiftActivity.SetCode(&code)
displayName := "Lunch"
shiftActivity.SetDisplayName(&displayName)
activities := []graphmodels.ShiftActivityable {
shiftActivity,
}
sharedShift.SetActivities(activities)
requestBody.SetSharedShift(sharedShift)
draftShift := graphmodels.NewShiftItem()
displayName := "Day shift"
draftShift.SetDisplayName(&displayName)
notes := "Please do inventory as part of your shift."
draftShift.SetNotes(¬es)
startDateTime , err := time.Parse(time.RFC3339, "2019-03-11T15:00:00Z")
draftShift.SetStartDateTime(&startDateTime)
endDateTime , err := time.Parse(time.RFC3339, "2019-03-12T00:00:00Z")
draftShift.SetEndDateTime(&endDateTime)
theme := graphmodels.BLUE_SCHEDULEENTITYTHEME
draftShift.SetTheme(&theme)
shiftActivity := graphmodels.NewShiftActivity()
isPaid := true
shiftActivity.SetIsPaid(&isPaid)
startDateTime , err := time.Parse(time.RFC3339, "2019-03-11T15:00:00Z")
shiftActivity.SetStartDateTime(&startDateTime)
endDateTime , err := time.Parse(time.RFC3339, "2019-03-11T15:30:00Z")
shiftActivity.SetEndDateTime(&endDateTime)
code := ""
shiftActivity.SetCode(&code)
displayName := "Lunch"
shiftActivity.SetDisplayName(&displayName)
activities := []graphmodels.ShiftActivityable {
shiftActivity,
}
draftShift.SetActivities(activities)
requestBody.SetDraftShift(draftShift)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
shifts, err := graphClient.Teams().ByTeamId("team-id").Schedule().Shifts().Post(context.Background(), requestBody, nil)
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Shift shift = new Shift();
shift.setId("SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8");
shift.setUserId("c5d0c76b-80c4-481c-be50-923cd8d680a1");
shift.setSchedulingGroupId("TAG_228940ed-ff84-4e25-b129-1b395cf78be0");
ShiftItem sharedShift = new ShiftItem();
sharedShift.setDisplayName("Day shift");
sharedShift.setNotes("Please do inventory as part of your shift.");
OffsetDateTime startDateTime = OffsetDateTime.parse("2019-03-11T15:00:00Z");
sharedShift.setStartDateTime(startDateTime);
OffsetDateTime endDateTime = OffsetDateTime.parse("2019-03-12T00:00:00Z");
sharedShift.setEndDateTime(endDateTime);
sharedShift.setTheme(ScheduleEntityTheme.Blue);
LinkedList<ShiftActivity> activities = new LinkedList<ShiftActivity>();
ShiftActivity shiftActivity = new ShiftActivity();
shiftActivity.setIsPaid(true);
OffsetDateTime startDateTime1 = OffsetDateTime.parse("2019-03-11T15:00:00Z");
shiftActivity.setStartDateTime(startDateTime1);
OffsetDateTime endDateTime1 = OffsetDateTime.parse("2019-03-11T15:15:00Z");
shiftActivity.setEndDateTime(endDateTime1);
shiftActivity.setCode("");
shiftActivity.setDisplayName("Lunch");
activities.add(shiftActivity);
sharedShift.setActivities(activities);
shift.setSharedShift(sharedShift);
ShiftItem draftShift = new ShiftItem();
draftShift.setDisplayName("Day shift");
draftShift.setNotes("Please do inventory as part of your shift.");
OffsetDateTime startDateTime2 = OffsetDateTime.parse("2019-03-11T15:00:00Z");
draftShift.setStartDateTime(startDateTime2);
OffsetDateTime endDateTime2 = OffsetDateTime.parse("2019-03-12T00:00:00Z");
draftShift.setEndDateTime(endDateTime2);
draftShift.setTheme(ScheduleEntityTheme.Blue);
LinkedList<ShiftActivity> activities1 = new LinkedList<ShiftActivity>();
ShiftActivity shiftActivity1 = new ShiftActivity();
shiftActivity1.setIsPaid(true);
OffsetDateTime startDateTime3 = OffsetDateTime.parse("2019-03-11T15:00:00Z");
shiftActivity1.setStartDateTime(startDateTime3);
OffsetDateTime endDateTime3 = OffsetDateTime.parse("2019-03-11T15:30:00Z");
shiftActivity1.setEndDateTime(endDateTime3);
shiftActivity1.setCode("");
shiftActivity1.setDisplayName("Lunch");
activities1.add(shiftActivity1);
draftShift.setActivities(activities1);
shift.setDraftShift(draftShift);
Shift result = graphClient.teams().byTeamId("{team-id}").schedule().shifts().post(shift);
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
const options = {
authProvider,
};
const client = Client.init(options);
const shift = {
id: 'SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8',
userId: 'c5d0c76b-80c4-481c-be50-923cd8d680a1',
schedulingGroupId: 'TAG_228940ed-ff84-4e25-b129-1b395cf78be0',
sharedShift: {
displayName: 'Day shift',
notes: 'Please do inventory as part of your shift.',
startDateTime: '2019-03-11T15:00:00Z',
endDateTime: '2019-03-12T00:00:00Z',
theme: 'blue',
activities: [
{
isPaid: true,
startDateTime: '2019-03-11T15:00:00Z',
endDateTime: '2019-03-11T15:15:00Z',
code: '',
displayName: 'Lunch'
}
]
},
draftShift: {
displayName: 'Day shift',
notes: 'Please do inventory as part of your shift.',
startDateTime: '2019-03-11T15:00:00Z',
endDateTime: '2019-03-12T00:00:00Z',
theme: 'blue',
activities: [
{
isPaid: true,
startDateTime: '2019-03-11T15:00:00Z',
endDateTime: '2019-03-11T15:30:00Z',
code: '',
displayName: 'Lunch'
}
]
}
};
await client.api('/teams/{teamId}/schedule/shifts')
.post(shift);
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\Shift;
use Microsoft\Graph\Generated\Models\ShiftItem;
use Microsoft\Graph\Generated\Models\ScheduleEntityTheme;
use Microsoft\Graph\Generated\Models\ShiftActivity;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Shift();
$requestBody->setId('SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8');
$requestBody->setUserId('c5d0c76b-80c4-481c-be50-923cd8d680a1');
$requestBody->setSchedulingGroupId('TAG_228940ed-ff84-4e25-b129-1b395cf78be0');
$sharedShift = new ShiftItem();
$sharedShift->setDisplayName('Day shift');
$sharedShift->setNotes('Please do inventory as part of your shift.');
$sharedShift->setStartDateTime(new \DateTime('2019-03-11T15:00:00Z'));
$sharedShift->setEndDateTime(new \DateTime('2019-03-12T00:00:00Z'));
$sharedShift->setTheme(new ScheduleEntityTheme('blue'));
$activitiesShiftActivity1 = new ShiftActivity();
$activitiesShiftActivity1->setIsPaid(true);
$activitiesShiftActivity1->setStartDateTime(new \DateTime('2019-03-11T15:00:00Z'));
$activitiesShiftActivity1->setEndDateTime(new \DateTime('2019-03-11T15:15:00Z'));
$activitiesShiftActivity1->setCode('');
$activitiesShiftActivity1->setDisplayName('Lunch');
$activitiesArray []= $activitiesShiftActivity1;
$sharedShift->setActivities($activitiesArray);
$requestBody->setSharedShift($sharedShift);
$draftShift = new ShiftItem();
$draftShift->setDisplayName('Day shift');
$draftShift->setNotes('Please do inventory as part of your shift.');
$draftShift->setStartDateTime(new \DateTime('2019-03-11T15:00:00Z'));
$draftShift->setEndDateTime(new \DateTime('2019-03-12T00:00:00Z'));
$draftShift->setTheme(new ScheduleEntityTheme('blue'));
$activitiesShiftActivity1 = new ShiftActivity();
$activitiesShiftActivity1->setIsPaid(true);
$activitiesShiftActivity1->setStartDateTime(new \DateTime('2019-03-11T15:00:00Z'));
$activitiesShiftActivity1->setEndDateTime(new \DateTime('2019-03-11T15:30:00Z'));
$activitiesShiftActivity1->setCode('');
$activitiesShiftActivity1->setDisplayName('Lunch');
$activitiesArray []= $activitiesShiftActivity1;
$draftShift->setActivities($activitiesArray);
$requestBody->setDraftShift($draftShift);
$result = $graphServiceClient->teams()->byTeamId('team-id')->schedule()->shifts()->post($requestBody)->wait();
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
Import-Module Microsoft.Graph.Teams
$params = @{
id = "SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8"
userId = "c5d0c76b-80c4-481c-be50-923cd8d680a1"
schedulingGroupId = "TAG_228940ed-ff84-4e25-b129-1b395cf78be0"
sharedShift = @{
displayName = "Day shift"
notes = "Please do inventory as part of your shift."
startDateTime = [System.DateTime]::Parse("2019-03-11T15:00:00Z")
endDateTime = [System.DateTime]::Parse("2019-03-12T00:00:00Z")
theme = "blue"
activities = @(
@{
isPaid = $true
startDateTime = [System.DateTime]::Parse("2019-03-11T15:00:00Z")
endDateTime = [System.DateTime]::Parse("2019-03-11T15:15:00Z")
code = ""
displayName = "Lunch"
}
)
}
draftShift = @{
displayName = "Day shift"
notes = "Please do inventory as part of your shift."
startDateTime = [System.DateTime]::Parse("2019-03-11T15:00:00Z")
endDateTime = [System.DateTime]::Parse("2019-03-12T00:00:00Z")
theme = "blue"
activities = @(
@{
isPaid = $true
startDateTime = [System.DateTime]::Parse("2019-03-11T15:00:00Z")
endDateTime = [System.DateTime]::Parse("2019-03-11T15:30:00Z")
code = ""
displayName = "Lunch"
}
)
}
}
New-MgTeamScheduleShift -TeamId $teamId -BodyParameter $params
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.shift import Shift
from msgraph.generated.models.shift_item import ShiftItem
from msgraph.generated.models.schedule_entity_theme import ScheduleEntityTheme
from msgraph.generated.models.shift_activity import ShiftActivity
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Shift(
id = "SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8",
user_id = "c5d0c76b-80c4-481c-be50-923cd8d680a1",
scheduling_group_id = "TAG_228940ed-ff84-4e25-b129-1b395cf78be0",
shared_shift = ShiftItem(
display_name = "Day shift",
notes = "Please do inventory as part of your shift.",
start_date_time = "2019-03-11T15:00:00Z",
end_date_time = "2019-03-12T00:00:00Z",
theme = ScheduleEntityTheme.Blue,
activities = [
ShiftActivity(
is_paid = True,
start_date_time = "2019-03-11T15:00:00Z",
end_date_time = "2019-03-11T15:15:00Z",
code = "",
display_name = "Lunch",
),
],
),
draft_shift = ShiftItem(
display_name = "Day shift",
notes = "Please do inventory as part of your shift.",
start_date_time = "2019-03-11T15:00:00Z",
end_date_time = "2019-03-12T00:00:00Z",
theme = ScheduleEntityTheme.Blue,
activities = [
ShiftActivity(
is_paid = True,
start_date_time = "2019-03-11T15:00:00Z",
end_date_time = "2019-03-11T15:30:00Z",
code = "",
display_name = "Lunch",
),
],
),
)
result = await graph_client.teams.by_team_id('team-id').schedule.shifts.post(request_body)
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
Das folgende Beispiel zeigt die Antwort.