Remarque
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de vous connecter ou de modifier des répertoires.
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de modifier des répertoires.
Espace de noms: microsoft.graph
Importante
Les API sous la version /beta dans Microsoft Graph sont susceptibles d’être modifiées. L’utilisation de ces API dans des applications de production n’est pas prise en charge. Pour déterminer si une API est disponible dans v1.0, utilisez le sélecteur Version .
Créez une activité utilisateur ou remplacez une activité utilisateur existante pour votre application. Si vous souhaitez créer une activité utilisateur et activityHistoryItems associée en une seule requête, vous pouvez utiliser l’insertion profonde.
Autorisations
Choisissez l’autorisation ou les autorisations marquées comme étant les moins privilégiées pour cette API. Utilisez une ou plusieurs autorisations privilégiées uniquement si votre application en a besoin. Pour plus d’informations sur les autorisations déléguées et d’application, voir Types d’autorisations. Pour en savoir plus sur ces autorisations, consultez la référence des autorisations.
| Type d’autorisation | Autorisations les moins privilégiées | Autorisations à privilèges plus élevés |
|---|---|---|
| Déléguée (compte professionnel ou scolaire) | UserActivity.ReadWrite.CreatedByApp | Non disponible. |
| Déléguée (compte Microsoft personnel) | UserActivity.ReadWrite.CreatedByApp | Non disponible. |
| Application | Non prise en charge. | Non prise en charge. |
Requête HTTP
PUT /me/activities/{appActivityId}
Remarque : L’appActivityId dans l’URL doit être sécurisé pour les URL (tous les caractères, à l’exception des caractères non réservés RFC 2396, doivent être convertis en leur représentation hexadécimale), mais l’appActivityId d’origine n’a pas besoin d’être sécurisé pour les URL.
En-têtes de demande
| Nom | Type | Description |
|---|---|---|
| Autorisation | string | Porteur {token}. Obligatoire. En savoir plus sur l’authentification et les autorisations. |
Corps de la demande
Dans le corps de la demande, fournissez une représentation JSON d’un objet d’activité .
Réponse
En cas de réussite, cette méthode renvoie le code de 201 Created réponse si l’activité a été créée ou 200 OK remplacée.
Exemples
Exemple 1 : créer une activité
Demande
L’exemple suivant illustre une demande.
PUT https://graph.microsoft.com/beta/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"
}
]
}
}
}
Réponse
L’exemple suivant illustre la réponse.
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"
}
}
Exemple 2 : Insertion profonde
Cet exemple crée une activité et un élément d’historique pour cette activité dans une requête.
Demande
L’exemple suivant illustre une demande.
PUT https://graph.microsoft.com/beta/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"
}
]
}
Réponse
L’exemple suivant illustre la réponse.
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
}
]
}