アクティビティを作成または置換する
名前空間: microsoft.graph
アプリの新しいユーザー アクティビティを作成するか、既存のユーザー アクティビティを置き換える。 ユーザー アクティビティとその関連する historyItems を 1 つの要求で作成する場合は、ディープ 挿入を 使用できます。
アクセス許可
この API を呼び出すには、次のいずれかのアクセス許可が必要です。アクセス許可の選択方法などの詳細については、「アクセス許可」を参照してください。
| アクセス許可の種類 | アクセス許可 (特権の小さいものから大きいものへ) |
|---|---|
| 委任 (職場または学校アカウント) | UserActivity.ReadWrite.CreatedByApp |
| 委任 (個人用 Microsoft アカウント) | UserActivity.ReadWrite.CreatedByApp |
| アプリケーション | サポートされていません。 |
HTTP 要求
PUT /me/activities/{appActivityId}
注: URL の appActivityId は URL セーフである必要があります (RFC 2396 の予約されていない文字を除くすべての文字は、16 進表記に変換する必要があります)、元の appActivityId は URL セーフである必要があります。
要求ヘッダー
| 名前 | 型 | 説明 |
|---|---|---|
| Authorization | string | ベアラー {トークン}。必須。 |
要求本文
要求本文で、アクティビティ オブジェクトの JSON 表記を 指定 します。
応答
成功した場合、アクティビティが作成された場合、またはアクティビティが置き換えられた場合、このメソッド 201 Created 200 OK は応答コードを返します。
例
例 1: アクティビティを作成する
要求
要求の例を次に示します。
PUT https://graph.microsoft.com/v1.0/me/activities/%2Farticle%3F12345
Content-type: application/json
{
"appActivityId": "/article?12345",
"activitySourceHost": "https://www.contoso.com",
"userTimezone": "Africa/Casablanca",
"appDisplayName": "Contoso, Ltd.",
"activationUrl": "https://www.contoso.com/article?id=12345",
"contentUrl": "https://www.contoso.com/article?id=12345",
"fallbackUrl": "https://www.contoso.com/article?id=12345",
"contentInfo": {
"@context": "https://schema.org",
"@type": "Article",
"author": "Jennifer Booth",
"name": "How to Tie a Reef Knot"
},
"visualElements": {
"attribution": {
"iconUrl": "https://www.contoso.com/icon",
"alternateText": "Contoso, Ltd.",
"addImageQuery": false
},
"description": "How to Tie a Reef Knot. A step-by-step visual guide to the art of nautical knot-tying.",
"backgroundColor": "#ff0000",
"displayText": "Contoso How-To: How to Tie a Reef Knot",
"content": {
"$schema": "https://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": "Contoso MainPage"
}
]
}
}
}
応答
応答の例を次に示します。
HTTP/1.1 200 OK
Content-Type: application/json
{
"activitySourceHost": "https://contoso.com",
"createdDateTime": "2017-06-09T20:54:43.969Z",
"lastModifiedDateTime": "2017-06-09T20:54:43.969Z",
"id": "14332800362997268276",
"appActivityId": "/article?12345",
"status": "updated",
"expirationDateTime": "2017-02-26T20:20:48.114Z",
"visualElements": {
"displayText": "Contoso How-To: How to Tie a Reef Knot",
"description": "How to Tie a Reef Knot. A step-by-step visual guide to the art of nautical knot-tying.",
"attribution": {
"iconUrl": "https://www.contoso.com/icon",
"alternateText": "Contoso, Ltd.",
"addImageQuery": "false"
},
"backgroundColor": "#ff0000",
"content": {
"$schema": "https://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": "Contoso MainPage"
}
]
}
},
"activationUrl": "https://www.contoso.com/article?id=12345",
"appDisplayName": "Contoso, Ltd.",
"userTimezone": "Africa/Casablanca",
"fallbackUrl": "https://www.contoso.com/article?id=12345",
"contentUrl": "https://www.contoso.com/article?id=12345",
"contentInfo": {
"@context": "https://schema.org",
"@type": "Article",
"author": "Jennifer Booth",
"name": "How to Tie a Reef Knot"
}
}
例 2: 深い挿入
この例では、1 つの要求で、そのアクティビティの新しいアクティビティと履歴アイテムを作成します。
要求
要求の例を次に示します。
PUT https://graph.microsoft.com/v1.0/me/activities/%2Farticle%3F12345
Content-type: application/json
{
"appActivityId": "/article?12345",
"activitySourceHost": "https://www.contoso.com",
"userTimezone": "Africa/Casablanca",
"appDisplayName": "Contoso, Ltd.",
"activationUrl": "https://www.contoso.com/article?id=12345",
"contentUrl": "https://www.contoso.com/article?id=12345",
"fallbackUrl": "https://www.contoso.com/article?id=12345",
"contentInfo": {
"@context": "https://schema.org",
"@type": "Article",
"author": "Jennifer Booth",
"name": "How to Tie a Reef Knot"
},
"visualElements": {
"attribution": {
"iconUrl": "https://www.contoso.com/icon",
"alternateText": "Contoso, Ltd.",
"addImageQuery": "false"
},
"description": "How to Tie a Reef Knot. A step-by-step visual guide to the art of nautical knot-tying.",
"backgroundColor": "#ff0000",
"displayText": "Contoso How-To: How to Tie a Reef Knot",
"content": {
"$schema": "https://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": "Contoso MainPage"
}
]
}
},
"historyItems": [
{
"userTimezone": "Africa/Casablanca",
"startedDateTime": "2018-02-26T20:54:04.345Z",
"lastActiveDateTime": "2018-02-26T20:54:24.345Z"
}
]
}
応答
応答の例を次に示します。
HTTP/1.1 200 OK
Content-Type: application/json
{
"activitySourceHost": "https://contoso.com",
"createdDateTime": "2017-06-09T20:54:43.969Z",
"lastModifiedDateTime": "2017-06-09T20:54:43.969Z",
"id": "14332800362997268276",
"appActivityId": "/article?12345",
"status": "updated",
"expirationDateTime": "2017-02-26T20:20:48.114Z",
"visualElements": {
"displayText": "Contoso How-To: How to Tie a Reef Knot",
"description": "How to Tie a Reef Knot. A step-by-step visual guide to the art of nautical knot-tying.",
"attribution": {
"iconUrl": "https://www.contoso.com/icon",
"alternateText": "Contoso, Ltd.",
"addImageQuery": "false"
},
"backgroundColor": "#ff0000",
"content": {
"$schema": "https://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": "Contoso MainPage"
}
]
}
},
"activationUrl": "https://www.contoso.com/article?id=12345",
"appDisplayName": "Contoso, Ltd.",
"userTimezone": "Africa/Casablanca",
"fallbackUrl": "https://www.contoso.com/article?id=12345",
"contentUrl": "https://www.contoso.com/article?id=12345",
"contentInfo": {
"@context": "https://schema.org",
"@type": "Article",
"author": "Jennifer Booth",
"name": "How to Tie a Reef Knot"
},
"historyItems": [
{
"status": "updated",
"userTimezone": "Africa/Casablanca",
"createdDateTime": "2018-04-12T21:42:42.495Z",
"lastModifiedDateTime": "2018-04-12T21:42:42.495Z",
"id": "61fc8f36-919f-4b73-89d4-1cb7b159d912",
"startedDateTime": "2018-02-26T20:54:04.345Z",
"lastActiveDateTime": "2018-02-26T20:54:24.345Z",
"expirationDateTime": "2018-05-12T21:42:42.495Z",
"activeDurationSeconds": 20
}
]
}
フィードバック
フィードバックの送信と表示