名前空間: microsoft.graph
重要
Microsoft Graph の /beta
バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。
注意
Outlook tasks API は非推奨となり、2022 年 8 月 20 日にデータの返しを停止しました。 代わりに To Do API を 使用します。
ユーザーのメールボックスの既定のタスク グループ (My Tasks
) と既定のタスク フォルダー (Tasks
) に Outlook タスクを作成します。
POST メソッドは、要求本文の startDateTime と dueDateTime の時間部分を常に無視し、指定されたタイム ゾーンで常に午前 0 時であると想定します。
既定では、この操作 (および GET、PATCH、および 完全な タスク操作) は、UTC で日付関連のプロパティを返します。
Prefer: outlook.timezone
ヘッダーを使用して、応答内のすべての日付関連プロパティを UTC 以外のタイム ゾーンで表すことができます。
この API は、次の国内クラウド展開で使用できます。
グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
✅ |
✅ |
✅ |
❌ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
委任 (職場または学校のアカウント) |
Tasks.ReadWrite |
注意事項なし。 |
委任 (個人用 Microsoft アカウント) |
Tasks.ReadWrite |
注意事項なし。 |
アプリケーション |
サポートされていません。 |
サポートされていません。 |
HTTP 要求
POST /me/outlook/tasks
POST /users/{id|userPrincipalName}/outlook/tasks
名前 |
説明 |
Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
優先: outlook.timezone |
応答のタイム プロパティのタイム ゾーンを指定します。これは、このヘッダーが指定されていない場合は UTC になります。 省略可能。 |
要求本文
要求本文で、 outlookTask オブジェクトの JSON 表現を指定します。
応答
成功した場合、このメソッドは応答コードと outlookTask オブジェクト201 Created
応答本文で返します。
例
要求
次の例は、 Prefer: outlook.timezone
ヘッダーの使用を示しています。 タスクを作成し、 startDateTime と dueDateTime を東部標準時 (EST) で表し、太平洋標準時 (PST) の Prefer
ヘッダーを含みます。
POST https://graph.microsoft.com/beta/me/outlook/tasks
Prefer: outlook.timezone="Pacific Standard Time"
Content-type: application/json
{
"subject": "Shop for children's weekend",
"startDateTime": {
"dateTime": "2016-05-03T09:00:00",
"timeZone": "Eastern Standard Time"
},
"dueDateTime": {
"dateTime": "2016-05-05T16:00:00",
"timeZone": "Eastern Standard Time"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new OutlookTask
{
Subject = "Shop for children's weekend",
StartDateTime = new DateTimeTimeZone
{
DateTime = "2016-05-03T09:00:00",
TimeZone = "Eastern Standard Time",
},
DueDateTime = new DateTimeTimeZone
{
DateTime = "2016-05-05T16:00:00",
TimeZone = "Eastern Standard Time",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Outlook.Tasks.PostAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Prefer", "outlook.timezone=\"Pacific Standard Time\"");
});
mgc-beta users outlook tasks create --user-id {user-id} --body '{\
"subject": "Shop for children's weekend",\
"startDateTime": {\
"dateTime": "2016-05-03T09:00:00",\
"timeZone": "Eastern Standard Time"\
},\
"dueDateTime": {\
"dateTime": "2016-05-05T16:00:00",\
"timeZone": "Eastern Standard Time"\
}\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("Prefer", "outlook.timezone=\"Pacific Standard Time\"")
configuration := &graphusers.OutlookTasksRequestBuilderPostRequestConfiguration{
Headers: headers,
}
requestBody := graphmodels.NewOutlookTask()
subject := "Shop for children's weekend"
requestBody.SetSubject(&subject)
startDateTime := graphmodels.NewDateTimeTimeZone()
dateTime := "2016-05-03T09:00:00"
startDateTime.SetDateTime(&dateTime)
timeZone := "Eastern Standard Time"
startDateTime.SetTimeZone(&timeZone)
requestBody.SetStartDateTime(startDateTime)
dueDateTime := graphmodels.NewDateTimeTimeZone()
dateTime := "2016-05-05T16:00:00"
dueDateTime.SetDateTime(&dateTime)
timeZone := "Eastern Standard Time"
dueDateTime.SetTimeZone(&timeZone)
requestBody.SetDueDateTime(dueDateTime)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
tasks, err := graphClient.Me().Outlook().Tasks().Post(context.Background(), requestBody, configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
OutlookTask outlookTask = new OutlookTask();
outlookTask.setSubject("Shop for children's weekend");
DateTimeTimeZone startDateTime = new DateTimeTimeZone();
startDateTime.setDateTime("2016-05-03T09:00:00");
startDateTime.setTimeZone("Eastern Standard Time");
outlookTask.setStartDateTime(startDateTime);
DateTimeTimeZone dueDateTime = new DateTimeTimeZone();
dueDateTime.setDateTime("2016-05-05T16:00:00");
dueDateTime.setTimeZone("Eastern Standard Time");
outlookTask.setDueDateTime(dueDateTime);
OutlookTask result = graphClient.me().outlook().tasks().post(outlookTask, requestConfiguration -> {
requestConfiguration.headers.add("Prefer", "outlook.timezone=\"Pacific Standard Time\"");
});
const options = {
authProvider,
};
const client = Client.init(options);
const outlookTask = {
subject: 'Shop for children\'s weekend',
startDateTime: {
dateTime: '2016-05-03T09:00:00',
timeZone: 'Eastern Standard Time'
},
dueDateTime: {
dateTime: '2016-05-05T16:00:00',
timeZone: 'Eastern Standard Time'
}
};
await client.api('/me/outlook/tasks')
.version('beta')
.post(outlookTask);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Outlook\Tasks\TasksRequestBuilderPostRequestConfiguration;
use Microsoft\Graph\Beta\Generated\Models\OutlookTask;
use Microsoft\Graph\Beta\Generated\Models\DateTimeTimeZone;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new OutlookTask();
$requestBody->setSubject('Shop for children\'s weekend');
$startDateTime = new DateTimeTimeZone();
$startDateTime->setDateTime('2016-05-03T09:00:00');
$startDateTime->setTimeZone('Eastern Standard Time');
$requestBody->setStartDateTime($startDateTime);
$dueDateTime = new DateTimeTimeZone();
$dueDateTime->setDateTime('2016-05-05T16:00:00');
$dueDateTime->setTimeZone('Eastern Standard Time');
$requestBody->setDueDateTime($dueDateTime);
$requestConfiguration = new TasksRequestBuilderPostRequestConfiguration();
$headers = [
'Prefer' => 'outlook.timezone="Pacific Standard Time"',
];
$requestConfiguration->headers = $headers;
$result = $graphServiceClient->me()->outlook()->tasks()->post($requestBody, $requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Users
$params = @{
subject = "Shop for children's weekend"
startDateTime = @{
dateTime = "2016-05-03T09:00:00"
timeZone = "Eastern Standard Time"
}
dueDateTime = @{
dateTime = "2016-05-05T16:00:00"
timeZone = "Eastern Standard Time"
}
}
# A UPN can also be used as -UserId.
New-MgBetaUserOutlookTask -UserId $userId -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.users.item.outlook.tasks.tasks_request_builder import TasksRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
from msgraph_beta.generated.models.outlook_task import OutlookTask
from msgraph_beta.generated.models.date_time_time_zone import DateTimeTimeZone
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = OutlookTask(
subject = "Shop for children's weekend",
start_date_time = DateTimeTimeZone(
date_time = "2016-05-03T09:00:00",
time_zone = "Eastern Standard Time",
),
due_date_time = DateTimeTimeZone(
date_time = "2016-05-05T16:00:00",
time_zone = "Eastern Standard Time",
),
)
request_configuration = RequestConfiguration()
request_configuration.headers.add("Prefer", "outlook.timezone=\"Pacific Standard Time\"")
result = await graph_client.me.outlook.tasks.post(request_body, request_configuration = request_configuration)
要求本文で、 outlookTask オブジェクトの JSON 表現を指定します。
応答
POST メソッドは、要求本文の startDateTime と dueDateTime の時間部分を無視し、指定されたタイム ゾーン (EST) で常に午前 0 時になると想定します。
Prefer
ヘッダーでは PST が指定されているため、POST メソッドは応答内のすべての日付関連プロパティを PST で表記します。
特に、 startDateTime プロパティと dueDateTime プロパティの場合、POST メソッドは EST の午前 0 時を PST に変換し、応答で PST で返します。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 201 Created
Content-type: application/json
{
"id": "AAMkADA1MHgwAAA=",
"createdDateTime": "2016-04-22T15:19:18.9526004-07:00",
"lastModifiedDateTime": "2016-04-22T15:19:19.015101-07:00",
"changeKey": "1/KC9Vmu40G3DwB6Lgs7MAAAIW9XXA==",
"categories": [ ],
"assignedTo": null,
"body": {
"contentType": "Text",
"content": ""
},
"completedDateTime": null,
"dueDateTime": {
"dateTime": "2016-05-04T021:00:00.0000000",
"timeZone": "Pacific Standard Time"
},
"hasAttachments":false,
"importance": "normal",
"isReminderOn": false,
"owner": "Administrator",
"parentFolderId": "AQMkADA1MTEgAAAA==",
"recurrence": null,
"reminderDateTime": null,
"sensitivity": "Normal",
"startDateTime": {
"dateTime": "2016-05-02T21:00:00.0000000",
"timeZone": "Pacific Standard Time"
},
"status": "notStarted",
"subject": "Shop for children's weekend"
}