Update openShift
Article
02/18/2023
8 contributors
Feedback
In this article
Namespace: microsoft.graph
Update the properties of an openShift object.
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions .
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
Schedule.ReadWrite.All, Group.ReadWrite.All
Delegated (personal Microsoft account)
Not supported.
Application
Schedule.ReadWrite.All
Note : This API supports admin permissions. Global admins can access groups that they are not a member of.
HTTP request
PUT /teams/{id}/schedule/openShifts/{openShiftId}
Name
Description
Authorization
Bearer {token}. Required.
Content-type
application/json. Required.
Request body
Provide the modified openShift object in the request body for this method.
Property
Type
Description
draftOpenShift
openShiftItem
An unpublished open shift.
schedulingGroupId
String
Scheduling group ID.
sharedOpenShift
openShiftItem
A published open shift.
Response
If successful, this method returns a 200 OK
response code and an updated openShift object in the response body.
Examples
Request
The following is an example of the request.
PATCH https://graph.microsoft.com/v1.0/teams/3d88b7a2-f988-4f4b-bb34-d66df66af126/schedule/openShifts/OPNSHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8
Content-type: application/json
{
"schedulingGroupId": "TAG_228940ed-ff84-4e25-b129-1b395cf78be0",
"sharedOpenShift": {
"notes": "Inventory Management",
"openSlotCount":5,
"displayName": "Field shift",
"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
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new OpenShift
{
SchedulingGroupId = "TAG_228940ed-ff84-4e25-b129-1b395cf78be0",
SharedOpenShift = new OpenShiftItem
{
Notes = "Inventory Management",
OpenSlotCount = 5,
DisplayName = "Field shift",
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,
};
var result = await graphClient.Teams["{team-id}"].Schedule.OpenShifts["{openShift-id}"].PatchAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestBody := graphmodels.NewOpenShift()
schedulingGroupId := "TAG_228940ed-ff84-4e25-b129-1b395cf78be0"
requestBody.SetSchedulingGroupId(&schedulingGroupId)
sharedOpenShift := graphmodels.NewOpenShiftItem()
notes := "Inventory Management"
sharedOpenShift.SetNotes(¬es)
openSlotCount := int32(5)
sharedOpenShift.SetOpenSlotCount(&openSlotCount)
displayName := "Field shift"
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)
result, err := graphClient.Teams().ByTeamId("team-id").Schedule().OpenShifts().ByOpenShiftId("openShift-id").Patch(context.Background(), requestBody, nil)
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();
OpenShift openShift = new OpenShift();
openShift.schedulingGroupId = "TAG_228940ed-ff84-4e25-b129-1b395cf78be0";
OpenShiftItem sharedOpenShift = new OpenShiftItem();
sharedOpenShift.notes = "Inventory Management";
sharedOpenShift.openSlotCount = 5;
sharedOpenShift.displayName = "Field shift";
sharedOpenShift.startDateTime = OffsetDateTimeSerializer.deserialize("2018-10-04T00:58:45.34Z");
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.34Z");
activities.endDateTime = OffsetDateTimeSerializer.deserialize("2018-10-04T01:58:45.34Z");
activities.code = "";
activities.displayName = "Lunch";
activitiesList.add(activities);
sharedOpenShift.activities = activitiesList;
openShift.sharedOpenShift = sharedOpenShift;
openShift.draftOpenShift = null;
graphClient.teams("3d88b7a2-f988-4f4b-bb34-d66df66af126").schedule().openShifts("OPNSHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8")
.buildRequest()
.patch(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 = {
schedulingGroupId: 'TAG_228940ed-ff84-4e25-b129-1b395cf78be0',
sharedOpenShift: {
notes: 'Inventory Management',
openSlotCount: 5,
displayName: 'Field shift',
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
};
await client.api('/teams/3d88b7a2-f988-4f4b-bb34-d66df66af126/schedule/openShifts/OPNSHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8')
.update(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 FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new OpenShift();
$requestBody->setSchedulingGroupId('TAG_228940ed-ff84-4e25-b129-1b395cf78be0');
$sharedOpenShift = new OpenShiftItem();
$sharedOpenShift->setNotes('Inventory Management');
$sharedOpenShift->setOpenSlotCount(5);
$sharedOpenShift->setDisplayName('Field shift');
$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);
$result = $graphServiceClient->teams()->byTeamId('team-id')->schedule()->openShifts()->byOpenShiftId('openShift-id')->patch($requestBody);
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 = @{
schedulingGroupId = "TAG_228940ed-ff84-4e25-b129-1b395cf78be0"
sharedOpenShift = @{
notes = "Inventory Management"
openSlotCount = 5
displayName = "Field shift"
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
}
Update-MgTeamScheduleOpenShift -TeamId $teamId -OpenShiftId $openShiftId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
The following is an example of the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "OPNSHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8",
"schedulingGroupId": "TAG_228940ed-ff84-4e25-b129-1b395cf78be0",
"sharedOpenShift": {
"notes": "Inventory Management",
"openSlotCount":5,
"displayName": "Day shift",
"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": "John Doe"
}
}
}