名前空間: microsoft.graph
スケジュールに新しい シフト インスタンスを作成 します。
シフトの継続時間を 1 分未満または 24 時間より長くすることはできません。
この API は、次の国内クラウド展開で使用できます。
| グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
| ✅ |
❌ |
❌ |
❌ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
| アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
| 委任 (職場または学校のアカウント) |
Schedule.ReadWrite.All |
Group.ReadWrite.All |
| 委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
サポートされていません。 |
| アプリケーション |
Schedule.ReadWrite.All |
注意事項なし。 |
HTTP 要求
POST /teams/{teamId}/schedule/shifts
| ヘッダー |
値 |
| Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
| Content-Type |
application/json. Required. |
| MS-APP-ACTS-AS (非推奨) |
ユーザー ID (GUID)。 承認トークンがアプリケーション トークンの場合にのみ必要です。それ以外の場合は省略可能です。
MS-APP-ACTS-AS ヘッダーは非推奨となり、アプリケーション トークンでは不要になりました。 |
要求本文
要求本文で、変更された シフト オブジェクトの JSON 表現を指定します。
次の表に、 シフト オブジェクトを作成するときに使用できるプロパティを示します。
| プロパティ |
型 |
説明 |
| draftShift |
shiftItem |
シフトの下書き変更。 下書きの変更は、マネージャーにのみ表示されます。 変更は、 共有時に従業員に表示されます。これにより、 draftShift から sharedShift プロパティに変更がコピーされます。 Eiher draShift または sharedShift を nullする必要があります。 |
| isStagedForDeletion |
ブール値 |
シフトは削除対象としてマークされます。これは、スケジュールが共有されるときに完了するプロセスです。 省略可能。 |
| schedulingGroupId |
文字列 |
シフトの一部であるスケジューリング グループの ID。 必須です。 |
| sharedShift |
shiftItem |
従業員とマネージャーの両方が表示できる、この シフト の共有バージョン。
sharedShift プロパティにUpdates、Teams クライアントのユーザーに通知を送信します。 Eiher draShift または sharedShift を nullする必要があります。 |
| userId |
String |
シフトに割り当てられたユーザーの ID。 必須です。 |
応答
成功した場合、このメソッドは 201 Created 応答コードと応答本文の シフト オブジェクトを返します。
例
要求
次の例は要求を示しています。
POST https://graph.microsoft.com/v1.0/teams/{teamId}/schedule/shifts
Content-type: application/json
{
"userId": "5ca83ce7-291d-43b7-bf53-af79eef4bc1d",
"draftShift": {
"displayName": null,
"startDateTime": "2024-10-08T15:00:00Z",
"endDateTime": "2024-10-09T00:00:00Z",
"theme": "blue",
"notes": null,
"activities": []
},
"sharedShift": null,
"isStagedForDeletion": false
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Shift
{
UserId = "5ca83ce7-291d-43b7-bf53-af79eef4bc1d",
DraftShift = new ShiftItem
{
DisplayName = null,
StartDateTime = DateTimeOffset.Parse("2024-10-08T15:00:00Z"),
EndDateTime = DateTimeOffset.Parse("2024-10-09T00:00:00Z"),
Theme = ScheduleEntityTheme.Blue,
Notes = null,
Activities = new List<ShiftActivity>
{
},
},
SharedShift = null,
IsStagedForDeletion = false,
};
// 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);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// 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()
userId := "5ca83ce7-291d-43b7-bf53-af79eef4bc1d"
requestBody.SetUserId(&userId)
draftShift := graphmodels.NewShiftItem()
displayName := null
draftShift.SetDisplayName(&displayName)
startDateTime , err := time.Parse(time.RFC3339, "2024-10-08T15:00:00Z")
draftShift.SetStartDateTime(&startDateTime)
endDateTime , err := time.Parse(time.RFC3339, "2024-10-09T00:00:00Z")
draftShift.SetEndDateTime(&endDateTime)
theme := graphmodels.BLUE_SCHEDULEENTITYTHEME
draftShift.SetTheme(&theme)
notes := null
draftShift.SetNotes(¬es)
activities := []graphmodels.ShiftActivityable {
}
draftShift.SetActivities(activities)
requestBody.SetDraftShift(draftShift)
sharedShift := null
requestBody.SetSharedShift(&sharedShift)
isStagedForDeletion := false
requestBody.SetIsStagedForDeletion(&isStagedForDeletion)
// 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)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Shift shift = new Shift();
shift.setUserId("5ca83ce7-291d-43b7-bf53-af79eef4bc1d");
ShiftItem draftShift = new ShiftItem();
draftShift.setDisplayName(null);
OffsetDateTime startDateTime = OffsetDateTime.parse("2024-10-08T15:00:00Z");
draftShift.setStartDateTime(startDateTime);
OffsetDateTime endDateTime = OffsetDateTime.parse("2024-10-09T00:00:00Z");
draftShift.setEndDateTime(endDateTime);
draftShift.setTheme(ScheduleEntityTheme.Blue);
draftShift.setNotes(null);
LinkedList<ShiftActivity> activities = new LinkedList<ShiftActivity>();
draftShift.setActivities(activities);
shift.setDraftShift(draftShift);
shift.setSharedShift(null);
shift.setIsStagedForDeletion(false);
Shift result = graphClient.teams().byTeamId("{team-id}").schedule().shifts().post(shift);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
const options = {
authProvider,
};
const client = Client.init(options);
const shift = {
userId: '5ca83ce7-291d-43b7-bf53-af79eef4bc1d',
draftShift: {
displayName: null,
startDateTime: '2024-10-08T15:00:00Z',
endDateTime: '2024-10-09T00:00:00Z',
theme: 'blue',
notes: null,
activities: []
},
sharedShift: null,
isStagedForDeletion: false
};
await client.api('/teams/{teamId}/schedule/shifts')
.post(shift);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
<?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->setUserId('5ca83ce7-291d-43b7-bf53-af79eef4bc1d');
$draftShift = new ShiftItem();
$draftShift->setDisplayName(null);
$draftShift->setStartDateTime(new \DateTime('2024-10-08T15:00:00Z'));
$draftShift->setEndDateTime(new \DateTime('2024-10-09T00:00:00Z'));
$draftShift->setTheme(new ScheduleEntityTheme('blue'));
$draftShift->setNotes(null);
$draftShift->setActivities([ ]);
$requestBody->setDraftShift($draftShift);
$requestBody->setSharedShift(null);
$requestBody->setIsStagedForDeletion(false);
$result = $graphServiceClient->teams()->byTeamId('team-id')->schedule()->shifts()->post($requestBody)->wait();
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
Import-Module Microsoft.Graph.Teams
$params = @{
userId = "5ca83ce7-291d-43b7-bf53-af79eef4bc1d"
draftShift = @{
displayName = $null
startDateTime = [System.DateTime]::Parse("2024-10-08T15:00:00Z")
endDateTime = [System.DateTime]::Parse("2024-10-09T00:00:00Z")
theme = "blue"
notes = $null
activities = @(
)
}
sharedShift = $null
isStagedForDeletion = $false
}
New-MgTeamScheduleShift -TeamId $teamId -BodyParameter $params
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
# 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(
user_id = "5ca83ce7-291d-43b7-bf53-af79eef4bc1d",
draft_shift = ShiftItem(
display_name = None,
start_date_time = "2024-10-08T15:00:00Z",
end_date_time = "2024-10-09T00:00:00Z",
theme = ScheduleEntityTheme.Blue,
notes = None,
activities = [
],
),
shared_shift = None,
is_staged_for_deletion = False,
)
result = await graph_client.teams.by_team_id('team-id').schedule.shifts.post(request_body)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 201 Created
Content-type: application/json
{
"id": "SHFT_0f004eda-32a6-4f0c-a076-18f76d997a55",
"createdDateTime": "2024-11-08T23:49:13.877Z",
"lastModifiedDateTime": "2024-11-08T23:49:13.877Z",
"schedulingGroupId": "TAG_4ab7d329-1f7e-4eaf-ba93-63f1ff3f3c4a",
"userId": "5ca83ce7-291d-43b7-bf53-af79eef4bc1d",
"sharedShift": null,
"lastModifiedBy": {
"application": null,
"device": null,
"user": {
"id": "366c0b19-49b1-41b5-a03f-9f3887bd0ed8",
"displayName": "John Doe",
"userIdentityType": "aadUser",
"tenantId": null
}
},
"draftShift": {
"displayName": null,
"startDateTime": "2024-10-08T15:00:00Z",
"endDateTime": "2024-10-09T00:00:00Z",
"theme": "blue",
"notes": null,
"activities": []
},
"isStagedForDeletion": false
}