名前空間: microsoft.graph
重要
Microsoft Graph の /beta バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。
新しい timeOffReason を作成します。
この API は、次の国内クラウド展開で使用できます。
| グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
| ✅ |
❌ |
❌ |
❌ |
アクセス許可
この API を呼び出すには、次のいずれかのアクセス許可が必要です。 アクセス許可の選択方法などの詳細については、「アクセス許可」を参照してください。
この API では、管理者のアクセス許可がサポートされています。 管理者ロールを持つユーザーは、メンバーではないチームにアクセスできます。
| アクセス許可の種類 |
アクセス許可 (特権の小さいものから大きいものへ) |
| 委任 (職場または学校のアカウント) |
Group.ReadWrite.All |
| 委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
| アプリケーション |
Schedule.ReadWrite.All* |
HTTP 要求
POST /teams/{teamId}/schedule/timeOffReasons
| ヘッダー |
値 |
| Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
| Content-Type |
application/json. Required. |
| MS-APP-ACTS-AS (非推奨) |
ユーザー ID (GUID)。 承認トークンがアプリケーション トークンの場合にのみ必要です。それ以外の場合は省略可能です。
MS-APP-ACTS-AS ヘッダーは非推奨となり、アプリケーション トークンでは不要になりました。 |
応答
成功した場合、このメソッドは応答コードを 201 Created し、応答本文に timeOffReason オブジェクトを返します。
例
要求
次の例は要求を示しています。
POST https://graph.microsoft.com/beta/teams/{teamId}/schedule/timeOffReasons
Content-type: application/json
{
"displayName": "Vacation",
"code": "VacationCode",
"iconType": "plane",
"isActive": true
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new TimeOffReason
{
DisplayName = "Vacation",
Code = "VacationCode",
IconType = TimeOffReasonIconType.Plane,
IsActive = true,
};
// 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.TimeOffReasons.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.NewTimeOffReason()
displayName := "Vacation"
requestBody.SetDisplayName(&displayName)
code := "VacationCode"
requestBody.SetCode(&code)
iconType := graphmodels.PLANE_TIMEOFFREASONICONTYPE
requestBody.SetIconType(&iconType)
isActive := true
requestBody.SetIsActive(&isActive)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
timeOffReasons, err := graphClient.Teams().ByTeamId("team-id").Schedule().TimeOffReasons().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
TimeOffReason timeOffReason = new TimeOffReason();
timeOffReason.setDisplayName("Vacation");
timeOffReason.setCode("VacationCode");
timeOffReason.setIconType(TimeOffReasonIconType.Plane);
timeOffReason.setIsActive(true);
TimeOffReason result = graphClient.teams().byTeamId("{team-id}").schedule().timeOffReasons().post(timeOffReason);
const options = {
authProvider,
};
const client = Client.init(options);
const timeOffReason = {
displayName: 'Vacation',
code: 'VacationCode',
iconType: 'plane',
isActive: true
};
await client.api('/teams/{teamId}/schedule/timeOffReasons')
.version('beta')
.post(timeOffReason);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\TimeOffReason;
use Microsoft\Graph\Beta\Generated\Models\TimeOffReasonIconType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new TimeOffReason();
$requestBody->setDisplayName('Vacation');
$requestBody->setCode('VacationCode');
$requestBody->setIconType(new TimeOffReasonIconType('plane'));
$requestBody->setIsActive(true);
$result = $graphServiceClient->teams()->byTeamId('team-id')->schedule()->timeOffReasons()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Teams
$params = @{
displayName = "Vacation"
code = "VacationCode"
iconType = "plane"
isActive = $true
}
New-MgBetaTeamScheduleTimeOffReason -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_reason import TimeOffReason
from msgraph_beta.generated.models.time_off_reason_icon_type import TimeOffReasonIconType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = TimeOffReason(
display_name = "Vacation",
code = "VacationCode",
icon_type = TimeOffReasonIconType.Plane,
is_active = True,
)
result = await graph_client.teams.by_team_id('team-id').schedule.time_off_reasons.post(request_body)
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 201 Created
Content-type: application/json
{
"id": "TOR_891045ca-b5d2-406b-aa06-a3c8921245d7",
"createdDateTime": "2019-03-12T22:10:38.242Z",
"lastModifiedDateTime": "2019-03-12T22:10:38.242Z",
"displayName": "Vacation",
"code": "VacationCode",
"iconType": "plane",
"isActive": true,
"lastModifiedBy": {
"application": null,
"device": null,
"conversation": null,
"user": {
"id": "366c0b19-49b1-41b5-a03f-9f3887bd0ed8",
"displayName": "John Doe"
}
}
}