Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
The following example shows a request.
POST https://graph.microsoft.com/v1.0/teams/788b75d2-a911-48c0-a5e2-dc98480457e3/schedule/openShifts
Authorization: Bearer {token}
Content-type: application/json
{
"id":"OPNSHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8",
"schedulingGroupId":"TAG_228940ed-ff84-4e25-b129-1b395cf78be0",
"sharedOpenShift":{
"notes":"InventoryManagement",
"openSlotCount":2,
"displayName":"Dayshift",
"startDateTime":"2018-10-04T00: 58: 45.340Z",
"endDateTime":"2018-10-04T09: 50: 45.332Z",
"theme":"white",
"activities":[
{
"isPaid":true,
"startDateTime":"2018-10-04T00: 58: 45.340Z",
"endDateTime":"2018-10-04T01: 58: 45.340Z",
"code":"",
"displayName":"Lunch"
}
]
},
"draftOpenShift":null,
"createdDateTime":"2019-03-14T04: 32: 51.451Z",
"lastModifiedDateTime":"2019-03-14T05: 32: 51.451Z",
"lastModifiedBy":{
"application":null,
"device":null,
"conversation":null,
"user":{
"id":"366c0b19-49b1-41b5-a03f-9f3887bd0ed8",
"displayName":"JohnDoe"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new OpenShift
{
Id = "OPNSHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8",
SchedulingGroupId = "TAG_228940ed-ff84-4e25-b129-1b395cf78be0",
SharedOpenShift = new OpenShiftItem
{
Notes = "InventoryManagement",
OpenSlotCount = 2,
DisplayName = "Dayshift",
StartDateTime = DateTimeOffset.Parse("2018-10-04T00: 58: 45.340Z"),
EndDateTime = DateTimeOffset.Parse("2018-10-04T09: 50: 45.332Z"),
Theme = ScheduleEntityTheme.White,
Activities = new List<ShiftActivity>
{
new ShiftActivity
{
IsPaid = true,
StartDateTime = DateTimeOffset.Parse("2018-10-04T00: 58: 45.340Z"),
EndDateTime = DateTimeOffset.Parse("2018-10-04T01: 58: 45.340Z"),
Code = "",
DisplayName = "Lunch",
},
},
},
DraftOpenShift = null,
CreatedDateTime = DateTimeOffset.Parse("2019-03-14T04: 32: 51.451Z"),
LastModifiedDateTime = DateTimeOffset.Parse("2019-03-14T05: 32: 51.451Z"),
LastModifiedBy = new IdentitySet
{
Application = null,
Device = null,
User = new Identity
{
Id = "366c0b19-49b1-41b5-a03f-9f3887bd0ed8",
DisplayName = "JohnDoe",
},
AdditionalData = new Dictionary<string, object>
{
{
"conversation" , null
},
},
},
};
// 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.OpenShifts.PostAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Authorization", "Bearer {token}");
});
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc teams schedule open-shifts create --team-id {team-id} --body '{\
"id":"OPNSHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8",\
"schedulingGroupId":"TAG_228940ed-ff84-4e25-b129-1b395cf78be0",\
"sharedOpenShift":{\
"notes":"InventoryManagement",\
"openSlotCount":2,\
"displayName":"Dayshift",\
"startDateTime":"2018-10-04T00: 58: 45.340Z",\
"endDateTime":"2018-10-04T09: 50: 45.332Z",\
"theme":"white",\
"activities":[\
{\
"isPaid":true,\
"startDateTime":"2018-10-04T00: 58: 45.340Z",\
"endDateTime":"2018-10-04T01: 58: 45.340Z",\
"code":"",\
"displayName":"Lunch"\
}\
]\
},\
"draftOpenShift":null,\
"createdDateTime":"2019-03-14T04: 32: 51.451Z",\
"lastModifiedDateTime":"2019-03-14T05: 32: 51.451Z",\
"lastModifiedBy":{\
"application":null,\
"device":null,\
"conversation":null,\
"user":{\
"id":"366c0b19-49b1-41b5-a03f-9f3887bd0ed8",\
"displayName":"JohnDoe"\
}\
}\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
import (
"context"
"time"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
graphteams "github.com/microsoftgraph/msgraph-sdk-go/teams"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
headers := abstractions.NewRequestHeaders()
headers.Add("Authorization", "Bearer {token}")
configuration := &graphteams.TeamItemScheduleOpenShiftsRequestBuilderPostRequestConfiguration{
Headers: headers,
}
requestBody := graphmodels.NewOpenShift()
id := "OPNSHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8"
requestBody.SetId(&id)
schedulingGroupId := "TAG_228940ed-ff84-4e25-b129-1b395cf78be0"
requestBody.SetSchedulingGroupId(&schedulingGroupId)
sharedOpenShift := graphmodels.NewOpenShiftItem()
notes := "InventoryManagement"
sharedOpenShift.SetNotes(¬es)
openSlotCount := int32(2)
sharedOpenShift.SetOpenSlotCount(&openSlotCount)
displayName := "Dayshift"
sharedOpenShift.SetDisplayName(&displayName)
startDateTime , err := time.Parse(time.RFC3339, "2018-10-04T00: 58: 45.340Z")
sharedOpenShift.SetStartDateTime(&startDateTime)
endDateTime , err := time.Parse(time.RFC3339, "2018-10-04T09: 50: 45.332Z")
sharedOpenShift.SetEndDateTime(&endDateTime)
theme := graphmodels.WHITE_SCHEDULEENTITYTHEME
sharedOpenShift.SetTheme(&theme)
shiftActivity := graphmodels.NewShiftActivity()
isPaid := true
shiftActivity.SetIsPaid(&isPaid)
startDateTime , err := time.Parse(time.RFC3339, "2018-10-04T00: 58: 45.340Z")
shiftActivity.SetStartDateTime(&startDateTime)
endDateTime , err := time.Parse(time.RFC3339, "2018-10-04T01: 58: 45.340Z")
shiftActivity.SetEndDateTime(&endDateTime)
code := ""
shiftActivity.SetCode(&code)
displayName := "Lunch"
shiftActivity.SetDisplayName(&displayName)
activities := []graphmodels.ShiftActivityable {
shiftActivity,
}
sharedOpenShift.SetActivities(activities)
requestBody.SetSharedOpenShift(sharedOpenShift)
draftOpenShift := null
requestBody.SetDraftOpenShift(&draftOpenShift)
createdDateTime , err := time.Parse(time.RFC3339, "2019-03-14T04: 32: 51.451Z")
requestBody.SetCreatedDateTime(&createdDateTime)
lastModifiedDateTime , err := time.Parse(time.RFC3339, "2019-03-14T05: 32: 51.451Z")
requestBody.SetLastModifiedDateTime(&lastModifiedDateTime)
lastModifiedBy := graphmodels.NewIdentitySet()
application := null
lastModifiedBy.SetApplication(&application)
device := null
lastModifiedBy.SetDevice(&device)
user := graphmodels.NewIdentity()
id := "366c0b19-49b1-41b5-a03f-9f3887bd0ed8"
user.SetId(&id)
displayName := "JohnDoe"
user.SetDisplayName(&displayName)
lastModifiedBy.SetUser(user)
additionalData := map[string]interface{}{
conversation := null
lastModifiedBy.SetConversation(&conversation)
}
lastModifiedBy.SetAdditionalData(additionalData)
requestBody.SetLastModifiedBy(lastModifiedBy)
openShifts, err := graphClient.Teams().ByTeamId("team-id").Schedule().OpenShifts().Post(context.Background(), requestBody, configuration)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new HeaderOption("Authorization", "Bearer {token}"));
OpenShift openShift = new OpenShift();
openShift.id = "OPNSHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8";
openShift.schedulingGroupId = "TAG_228940ed-ff84-4e25-b129-1b395cf78be0";
OpenShiftItem sharedOpenShift = new OpenShiftItem();
sharedOpenShift.notes = "InventoryManagement";
sharedOpenShift.openSlotCount = 2;
sharedOpenShift.displayName = "Dayshift";
sharedOpenShift.startDateTime = OffsetDateTimeSerializer.deserialize("2018-10-04T00: 58: 45.340Z");
sharedOpenShift.endDateTime = OffsetDateTimeSerializer.deserialize("2018-10-04T09: 50: 45.332Z");
sharedOpenShift.theme = ScheduleEntityTheme.WHITE;
LinkedList<ShiftActivity> activitiesList = new LinkedList<ShiftActivity>();
ShiftActivity activities = new ShiftActivity();
activities.isPaid = true;
activities.startDateTime = OffsetDateTimeSerializer.deserialize("2018-10-04T00: 58: 45.340Z");
activities.endDateTime = OffsetDateTimeSerializer.deserialize("2018-10-04T01: 58: 45.340Z");
activities.code = "";
activities.displayName = "Lunch";
activitiesList.add(activities);
sharedOpenShift.activities = activitiesList;
openShift.sharedOpenShift = sharedOpenShift;
openShift.draftOpenShift = null;
openShift.createdDateTime = OffsetDateTimeSerializer.deserialize("2019-03-14T04: 32: 51.451Z");
openShift.lastModifiedDateTime = OffsetDateTimeSerializer.deserialize("2019-03-14T05: 32: 51.451Z");
IdentitySet lastModifiedBy = new IdentitySet();
lastModifiedBy.application = null;
lastModifiedBy.device = null;
lastModifiedBy.conversation = null;
Identity user = new Identity();
user.id = "366c0b19-49b1-41b5-a03f-9f3887bd0ed8";
user.displayName = "JohnDoe";
lastModifiedBy.user = user;
openShift.lastModifiedBy = lastModifiedBy;
graphClient.teams("788b75d2-a911-48c0-a5e2-dc98480457e3").schedule().openShifts()
.buildRequest( requestOptions )
.post(openShift);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const openShift = {
id: 'OPNSHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8',
schedulingGroupId: 'TAG_228940ed-ff84-4e25-b129-1b395cf78be0',
sharedOpenShift: {
notes: 'InventoryManagement',
openSlotCount: 2,
displayName: 'Dayshift',
startDateTime: '2018-10-04T00: 58: 45.340Z',
endDateTime: '2018-10-04T09: 50: 45.332Z',
theme: 'white',
activities: [
{
isPaid: true,
startDateTime: '2018-10-04T00: 58: 45.340Z',
endDateTime: '2018-10-04T01: 58: 45.340Z',
code: '',
displayName: 'Lunch'
}
]
},
draftOpenShift: null,
createdDateTime: '2019-03-14T04: 32: 51.451Z',
lastModifiedDateTime: '2019-03-14T05: 32: 51.451Z',
lastModifiedBy: {
application: null,
device: null,
conversation: null,
user: {
id: '366c0b19-49b1-41b5-a03f-9f3887bd0ed8',
displayName: 'JohnDoe'
}
}
};
await client.api('/teams/788b75d2-a911-48c0-a5e2-dc98480457e3/schedule/openShifts')
.post(openShift);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new OpenShift();
$requestBody->setId('OPNSHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8');
$requestBody->setSchedulingGroupId('TAG_228940ed-ff84-4e25-b129-1b395cf78be0');
$sharedOpenShift = new OpenShiftItem();
$sharedOpenShift->setNotes('InventoryManagement');
$sharedOpenShift->setOpenSlotCount(2);
$sharedOpenShift->setDisplayName('Dayshift');
$sharedOpenShift->setStartDateTime(new \DateTime('2018-10-04T00: 58: 45.340Z'));
$sharedOpenShift->setEndDateTime(new \DateTime('2018-10-04T09: 50: 45.332Z'));
$sharedOpenShift->setTheme(new ScheduleEntityTheme('white'));
$activitiesShiftActivity1 = new ShiftActivity();
$activitiesShiftActivity1->setIsPaid(true);
$activitiesShiftActivity1->setStartDateTime(new \DateTime('2018-10-04T00: 58: 45.340Z'));
$activitiesShiftActivity1->setEndDateTime(new \DateTime('2018-10-04T01: 58: 45.340Z'));
$activitiesShiftActivity1->setCode('');
$activitiesShiftActivity1->setDisplayName('Lunch');
$activitiesArray []= $activitiesShiftActivity1;
$sharedOpenShift->setActivities($activitiesArray);
$requestBody->setSharedOpenShift($sharedOpenShift);
$requestBody->setDraftOpenShift(null);
$requestBody->setCreatedDateTime(new \DateTime('2019-03-14T04: 32: 51.451Z'));
$requestBody->setLastModifiedDateTime(new \DateTime('2019-03-14T05: 32: 51.451Z'));
$lastModifiedBy = new IdentitySet();
$lastModifiedBy->setApplication(null);
$lastModifiedBy->setDevice(null);
$lastModifiedByUser = new Identity();
$lastModifiedByUser->setId('366c0b19-49b1-41b5-a03f-9f3887bd0ed8');
$lastModifiedByUser->setDisplayName('JohnDoe');
$lastModifiedBy->setUser($lastModifiedByUser);
$additionalData = [
'conversation' => null,
];
$lastModifiedBy->setAdditionalData($additionalData);
$requestBody->setLastModifiedBy($lastModifiedBy);
$requestConfiguration = new OpenShiftsRequestBuilderPostRequestConfiguration();
$headers = [
'Authorization' => 'Bearer {token}',
];
$requestConfiguration->headers = $headers;
$result = $graphServiceClient->teams()->byTeamId('team-id')->schedule()->openShifts()->post($requestBody, $requestConfiguration)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Teams
$params = @{
id = "OPNSHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8"
schedulingGroupId = "TAG_228940ed-ff84-4e25-b129-1b395cf78be0"
sharedOpenShift = @{
notes = "InventoryManagement"
openSlotCount = 2
displayName = "Dayshift"
startDateTime = [System.DateTime]::Parse("2018-10-04T00: 58: 45.340Z")
endDateTime = [System.DateTime]::Parse("2018-10-04T09: 50: 45.332Z")
theme = "white"
activities = @(
@{
isPaid = $true
startDateTime = [System.DateTime]::Parse("2018-10-04T00: 58: 45.340Z")
endDateTime = [System.DateTime]::Parse("2018-10-04T01: 58: 45.340Z")
code = ""
displayName = "Lunch"
}
)
}
draftOpenShift = $null
createdDateTime = [System.DateTime]::Parse("2019-03-14T04: 32: 51.451Z")
lastModifiedDateTime = [System.DateTime]::Parse("2019-03-14T05: 32: 51.451Z")
lastModifiedBy = @{
application = $null
device = $null
conversation = $null
user = @{
id = "366c0b19-49b1-41b5-a03f-9f3887bd0ed8"
displayName = "JohnDoe"
}
}
}
New-MgTeamScheduleOpenShift -TeamId $teamId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(credentials, scopes)
request_body = OpenShift(
id = "OPNSHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8",
scheduling_group_id = "TAG_228940ed-ff84-4e25-b129-1b395cf78be0",
shared_open_shift = OpenShiftItem(
notes = "InventoryManagement",
open_slot_count = 2,
display_name = "Dayshift",
start_date_time = "2018-10-04T00: 58: 45.340Z",
end_date_time = "2018-10-04T09: 50: 45.332Z",
theme = ScheduleEntityTheme.White,
activities = [
ShiftActivity(
is_paid = True,
start_date_time = "2018-10-04T00: 58: 45.340Z",
end_date_time = "2018-10-04T01: 58: 45.340Z",
code = "",
display_name = "Lunch",
),
],
),
draft_open_shift = None,
created_date_time = "2019-03-14T04: 32: 51.451Z",
last_modified_date_time = "2019-03-14T05: 32: 51.451Z",
last_modified_by = IdentitySet(
application = None,
device = None,
user = Identity(
id = "366c0b19-49b1-41b5-a03f-9f3887bd0ed8",
display_name = "JohnDoe",
),
additional_data = {
"conversation" : None,
}
),
)
request_configuration = OpenShiftsRequestBuilder.OpenShiftsRequestBuilderPostRequestConfiguration()
request_configuration.headers.add("Authorization", "Bearer {token}")
result = await graph_client.teams.by_team_id('team-id').schedule.open_shifts.post(request_body, request_configuration = request_configuration)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
The following example shows the response.