Обновление chatMessage

Важно!

API версии /beta в Microsoft Graph могут быть изменены. Использование этих API в производственных приложениях не поддерживается. Чтобы определить, доступен ли API в версии 1.0, используйте селектор версий.

Обновление объекта chatMessage .

Вы можете обновить все свойства chatMessage в сценариях делегированных разрешений, за исключением свойства policyViolation и свойств только для чтения. Свойство policyViolation является единственным свойством, которое можно обновить в сценариях разрешений приложений.

Обновление работает только для чатов, в которых участниками беседы являются пользователи Microsoft Teams. Если один из участников использует Skype, операция завершается сбоем.

Этот метод не поддерживает федерацию. Только пользователь в клиенте, отправивший сообщение, может выполнять обновления защиты от потери данных (DLP) для указанного сообщения чата.

Примечание.

При использовании с разрешениями приложения этот API измеряется. Он поддерживает model=A модель оплаты. Дополнительные сведения см. в разделе Модели оплаты. Если в запросе не указана модель оплаты, будет использоваться режим оценки по умолчанию.

Этот API доступен в следующих национальных облачных развертываниях.

Глобальная служба Правительство США L4 Правительство США L5 (DOD) Китай управляется 21Vianet

Разрешения

Для вызова этого API требуется одно из следующих разрешений. Дополнительные сведения, включая сведения о том, как выбрать разрешения, см. в статье Разрешения.

Разрешения для канала

Тип разрешения Разрешения (в порядке повышения привилегий)
Делегированные (рабочая или учебная учетная запись) ChannelMessage.ReadWrite, Group.ReadWrite.All
Делегированные (личная учетная запись Майкрософт) Не поддерживается.
Приложение ChannelMessage.UpdatePolicyViolation.All, Group.ReadWrite.All**

Примечание.

Разрешение Group.ReadWrite.All поддерживается только для обратной совместимости. Рекомендуется обновить решения, чтобы использовать другое разрешение, указанное в предыдущей таблице, и избегать использования этих разрешений в будущем.

Разрешения для чата

Тип разрешения Разрешения (в порядке повышения привилегий)
Делегированные (рабочая или учебная учетная запись) Chat.ReadWrite
Делегированные (личная учетная запись Майкрософт) Не поддерживается.
Приложение Chat.UpdatePolicyViolation.All, Chat.ReadWrite.All

HTTP-запрос

Чтобы обновить chatMessage в канале, выполните приведенные далее действия.

PATCH /teams/(team-id)/channels/{channel-id}/messages/{message-id}
PATCH /teams/(team-id)/channels/{channel-id}/messages/{message-id}/replies/{reply-id}

Чтобы обновить chatMessage в чате, выполните приведенные далее действия.

PATCH /chats/{chatThread-id}/messages/{message-id}

Необязательные параметры запросов

Можно использовать model параметр запроса, который поддерживает только значение A, как показано в следующих примерах.

PATCH /teams/(team-id)/channels/{channel-id}/messages/{message-id}?model=A
PATCH /teams/(team-id)/channels/{channel-id}/messages/{message-id}/replies/{reply-id}?model=A
PATCH /chats/{chatThread-id}/messages/{message-id}?model=A

Если параметр не model указан, используется режим оценки .

Заголовки запросов

Имя Описание
Авторизация Bearer {token}. Обязательно. Дополнительные сведения о проверке подлинности и авторизации.
Content-Type application/json. Обязательно.

Текст запроса

Для приложений, использующих делегированные разрешения:

В тексте запроса укажите представление объекта chatMessage в формате JSON, указав свойства, которые необходимо изменить.

Для приложений, использующих разрешения приложений:

В тексте запроса укажите представление объекта chatMessage в формате JSON, указав только свойство policyViolation .

Отклик

Для приложений, использующих делегированные разрешения:

В случае успешного 204 No Content выполнения этот метод возвращает ответ.

Для приложений, использующих разрешения приложений:

В случае успешного 200 OK выполнения этот метод возвращает ответ.

Ошибки

Этот API имеет требования к лицензированию и оплате. Если эти требования не выполняются, API возвращает одну из следующих ошибок.

Пример типа ошибки Код состояния Примеры сообщений об ошибках
Не выполнены требования к лицензии E5 402 (требуется оплата) "...needs a valid license to access this API..."
"...tenant needs a valid license to access this API..."
Модель B не поддерживается для API 402 (требуется оплата) "...the 'model' query parameter does not support value 'B' for this API. Use billing model 'A'..."
Превышены возможности оценки 402 (требуется оплата) "...evaluation mode capacity has been exceeded. Use a valid billing model..."

Примеры

Пример 1. Обновление политикиViolation с помощью разрешений приложения

Запрос

В следующем примере показан запрос на обновление свойства policyViolation в сообщении канала Microsoft Teams с помощью разрешений приложения.

PATCH https://graph.microsoft.com/beta/teams/e1234567-e123-4276-55555-6232b0e3a89a/channels/a7654321-e321-0000-0000-123b0e3a00a/messages/19%3Aa21b0b0c05194ebc9e30000000000f61%40thread.skype
Content-Type: application/json

{
  "policyViolation": {
    "policyTip": {
      "generalText" : "This item has been blocked by the administrator.",
      "complianceUrl" : "https://contoso.com/dlp-policy-page",
      "matchedConditionDescriptions" : ["Credit Card Number"]
    },
    "verdictDetails" : "AllowOverrideWithoutJustification,AllowFalsePositiveOverride",
    "dlpAction" : "BlockAccess"
  }
}

Отклик

Ниже показан пример отклика.

HTTP/1.1 200 OK

Пример 2. Обновление любого свойства сообщения с помощью делегированных разрешений

Запрос

В следующем примере показан запрос на обновление свойств сообщения канала Microsoft Teams с помощью делегированных разрешений.

PATCH https://graph.microsoft.com/beta/teams/e1234567-e123-4276-55555-6232b0e3a89a/channels/a7654321-e321-0000-0000-123b0e3a00a/messages/19%3Aa21b0b0c05194ebc9e30000000000f61%40thread.skype
Content-Type: application/json

{
  "messageType": "message",
  "subject": null,
  "summary": null,
  "importance": "normal",
  "locale": "en-us",
  "from": {
    "application": null,
    "device": null,
    "user": {
      "id": "3b102402-813e-4e17-a6b2-f841aef1fdfc",
      "displayName": "Sumit Gupta",
      "userIdentityType": "aadUser"
    },
    "conversation": null
  },
  "body": {
    "contentType": "text",
    "content": "Edit text only"
  },
  "attachments": [],
  "mentions": [],
  "reactions": [],
  "messageHistory": []
}

Отклик

Ниже показан пример отклика.

HTTP/1.1 204 NoContent

Пример 3. Обновление упоминаний сообщения с помощью делегированных разрешений

Запрос

В следующем примере показан запрос на обновление упоминаний в сообщении канала Microsoft Teams с помощью делегированных разрешений.

PATCH https://graph.microsoft.com/beta/teams/e1234567-e123-4276-55555-6232b0e3a89a/channels/a7654321-e321-0000-0000-123b0e3a00a/messages/19%3Aa21b0b0c05194ebc9e30000000000f61%40thread.skype
Content-Type: application/json

{
  "messageType": "message",
  "deletedDateTime": null,
  "subject": null,
  "summary": null,
  "importance": "normal",
  "locale": "en-us",
  "from": {
    "application": null,
    "device": null,
    "conversation": null,
    "user": {
      "id": "6b3f3c54-d09c-4fdd-b146-9b514a8a4f40",
      "displayName": "Sumit Gupta",
      "userIdentityType": "aadUser"
    }
  },
  "body": {
    "contentType": "html",
    "content": "<div><div>\n<div>\n<div>\n<div>\n<div><at id=\"0\">Raghav</at><at id=\"1\">TestGlobalBot</at> YEAH"
  },
  "attachments": [],
  "mentions": [
    {
      "id": 0,
      "mentionText": "Raghav",
      "mentioned": {
        "application": null,
        "device": null,
        "conversation": null,
        "user": {
          "id": "f1b66449-b46d-49b0-9c3c-53c10234c818e",
          "displayName": "Raghav Mankad",
          "userIdentityType": "aadUser"
        }
      }
    },
    {
      "id": 1,
      "mentionText": "TestGlobalBot",
      "mentioned": {
        "application": {
          "id": "03a02232-d8f5-4970-a77e-6e8c76ce7a4e",
          "displayName": "TestGlobalBot",
          "applicationIdentityType": "bot"
        },
        "device": null,
        "conversation": null,
        "user": null
      }
    }
  ],
  "reactions": [],
  "messageHistory": []
}

Отклик

Ниже показан пример отклика.

HTTP/1.1 204 NoContent

Пример 4. Обновление содержимого с помощью вложений сообщения с использованием делегированных разрешений

Запрос

В следующем примере показан запрос на обновление вложений в сообщении канала Microsoft Teams с использованием делегированных разрешений.

PATCH https://graph.microsoft.com/beta/teams/e1234567-e123-4276-55555-6232b0e3a89a/channels/a7654321-e321-0000-0000-123b0e3a00a/messages/19%3Aa21b0b0c05194ebc9e30000000000f61%40thread.skype
Content-Type: application/json

{
  "messageType": "message",
  "subject": null,
  "summary": null,
  "importance": "normal",
  "locale": "en-us",
  "from": {
    "application": null,
    "device": null,
    "user": {
      "id": "3b102402-813e-4e17-a6b2-f841aef1fdfc",
      "displayName": "Sumit Gupta",
      "userIdentityType": "aadUser"
    },
    "conversation": null
  },
  "body": {
    "contentType": "html",
    "content": "<p><em>text</em></p><attachment id=\"e8f78756199240b88448ae0fc6db112d\"></attachment><attachment id=\"638464e32834471ea202007da60a5ae6\"></attachment>"
  },
  "attachments": [
    {
      "id": "e8f78756199240b88448ae0fc6db112d",
      "contentType": "application/vnd.microsoft.card.hero",
      "contentUrl": null,
      "content": "{\r\n  \"title\": \"*title*\",\r\n  \"subtitle\": \"*subtitle*\",\r\n  \"text\": \"Have you found yourself scratching your head trying to figure these questions out? Frustrated trying to access some of the goodies unique to the Microsoft Teams platform?  Well, fear not, Bot Builder SDK Extension for Teams in .NET and Node flavors is here!  Just head on over to Nuget or NPM to download our tasty helpers, sure to speed up your prep time so you can spend more time maximizing the flavor of the bots you're cooking up.Here’s a small sample of some recipes to whet your appetite.\",\r\n  \"images\": [\r\n    {\r\n      \"url\": \"https://us-api.asm.skype.com/v1/objects/0-eus-d8-ced0c9567ee7b0b233b987bd32f9eacd/views/img_preview\"\r\n    }\r\n  ],\r\n  \"buttons\": [\r\n    {\r\n      \"type\": \"openUrl\",\r\n      \"image\": \"https://urlp.asm.skype.com/v1/url/content?url=https%3a%2f%2fcdn2.iconfinder.com%2fdata%2ficons%2fsocial-icons-33%2f128%2fTrello-128.png\",\r\n      \"title\": \"😃😃 click me 😃😃\",\r\n      \"value\": \"http://microsoft.com\"\r\n    },\r\n    {\r\n      \"type\": \"imback\",\r\n      \"title\": \"&i am back& <>= \\\"\",\r\n      \"value\": \"&i am back& <>= \\\"\"\r\n    },\r\n    {\r\n      \"type\": \"openUrl\",\r\n      \"title\": \"Open URL\",\r\n      \"value\": \"http://google.com\"\r\n    }\r\n  ]\r\n}",
      "name": null,
      "thumbnailUrl": null
    },
    {
      "id": "638464e32834471ea202007da60a5ae6",
      "contentType": "application/vnd.microsoft.card.hero",
      "contentUrl": null,
      "content": "{\r\n  \"title\": \"*title*\",\r\n  \"subtitle\": \"*subtitle*\",\r\n  \"text\": \"Have you found yourself scratching your head trying to figure these questions out? Frustrated trying to access some of the goodies unique to the Microsoft Teams platform?  Well, fear not, Bot Builder SDK Extension for Teams in .NET and Node flavors is here!  Just head on over to Nuget or NPM to download our tasty helpers, sure to speed up your prep time so you can spend more time maximizing the flavor of the bots you're cooking up.Here’s a small sample of some recipes to whet your appetite.\",\r\n  \"images\": [\r\n    {\r\n      \"url\": \"https://us-api.asm.skype.com/v1/objects/0-eus-d8-ced0c9567ee7b0b233b987bd32f9eacd/views/img_preview\"\r\n    }\r\n  ],\r\n  \"buttons\": [\r\n    {\r\n      \"type\": \"messageBack\",\r\n      \"title\": \"&message back& <>= \\\"\",\r\n      \"text\": \"text = &message back& <>= \\\"\",\r\n      \"displayText\": \"displayText = &message back& <>= \\\"\",\r\n      \"value\": {\r\n        \"text\": \"some text 2\"\r\n      }\r\n    }\r\n  ]\r\n}",
      "name": null,
      "thumbnailUrl": null
    }
  ],
  "mentions": [],
  "reactions": [],
  "messageHistory": []
}

Отклик

Ниже показан пример отклика.

HTTP/1.1 204 NoContent

Пример 5. Обновление реакций в сообщении с помощью делегированных разрешений

Запрос

В следующем примере показан запрос на обновление свойства реакций в сообщении канала Microsoft Teams с использованием делегированных разрешений.

PATCH https://graph.microsoft.com/beta/teams/e1234567-e123-4276-55555-6232b0e3a89a/channels/a7654321-e321-0000-0000-123b0e3a00a/messages/19%3Aa21b0b0c05194ebc9e30000000000f61%40thread.skype
Content-Type: application/json

{
  "messageType": "message",
  "subject": null,
  "summary": null,
  "importance": "normal",
  "locale": "en-us",
  "from": {
    "application": null,
    "device": null,
    "user": {
      "id": "3b102402-813e-4e17-a6b2-f841aef1fdfc",
      "displayName": "Sumit Gupta",
      "userIdentityType": "aadUser"
    },
    "conversation": null
  },
  "body": {
    "contentType": "html",
    "content": "<p><em>text</em></p><attachment id=\"e8f78756199240b88448ae0fc6db112d\"></attachment><attachment id=\"638464e32834471ea202007da60a5ae6\"></attachment>"
  },
  "attachments": [
    {
      "id": "e8f78756199240b88448ae0fc6db112d",
      "contentType": "application/vnd.microsoft.card.hero",
      "contentUrl": null,
      "content": "{\r\n  \"title\": \"*title*\",\r\n  \"subtitle\": \"*subtitle*\",\r\n  \"text\": \"Have you found yourself scratching your head trying to figure these questions out? Frustrated trying to access some of the goodies unique to the Microsoft Teams platform?  Well, fear not, Bot Builder SDK Extension for Teams in .NET and Node flavors is here!  Just head on over to Nuget or NPM to download our tasty helpers, sure to speed up your prep time so you can spend more time maximizing the flavor of the bots you're cooking up.Here’s a small sample of some recipes to whet your appetite.\",\r\n  \"images\": [\r\n    {\r\n      \"url\": \"https://us-api.asm.skype.com/v1/objects/0-eus-d8-ced0c9567ee7b0b233b987bd32f9eacd/views/img_preview\"\r\n    }\r\n  ],\r\n  \"buttons\": [\r\n    {\r\n      \"type\": \"openUrl\",\r\n      \"image\": \"https://urlp.asm.skype.com/v1/url/content?url=https%3a%2f%2fcdn2.iconfinder.com%2fdata%2ficons%2fsocial-icons-33%2f128%2fTrello-128.png\",\r\n      \"title\": \"😃😃 click me 😃😃\",\r\n      \"value\": \"http://microsoft.com\"\r\n    },\r\n    {\r\n      \"type\": \"imback\",\r\n      \"title\": \"&i am back& <>= \\\"\",\r\n      \"value\": \"&i am back& <>= \\\"\"\r\n    },\r\n    {\r\n      \"type\": \"openUrl\",\r\n      \"title\": \"Open URL\",\r\n      \"value\": \"http://google.com\"\r\n    }\r\n  ]\r\n}",
      "name": null,
      "thumbnailUrl": null
    },
    {
      "id": "638464e32834471ea202007da60a5ae6",
      "contentType": "application/vnd.microsoft.card.hero",
      "contentUrl": null,
      "content": "{\r\n  \"title\": \"*title*\",\r\n  \"subtitle\": \"*subtitle*\",\r\n  \"text\": \"Have you found yourself scratching your head trying to figure these questions out? Frustrated trying to access some of the goodies unique to the Microsoft Teams platform?  Well, fear not, Bot Builder SDK Extension for Teams in .NET and Node flavors is here!  Just head on over to Nuget or NPM to download our tasty helpers, sure to speed up your prep time so you can spend more time maximizing the flavor of the bots you're cooking up.Here’s a small sample of some recipes to whet your appetite.\",\r\n  \"images\": [\r\n    {\r\n      \"url\": \"https://us-api.asm.skype.com/v1/objects/0-eus-d8-ced0c9567ee7b0b233b987bd32f9eacd/views/img_preview\"\r\n    }\r\n  ],\r\n  \"buttons\": [\r\n    {\r\n      \"type\": \"messageBack\",\r\n      \"title\": \"&message back& <>= \\\"\",\r\n      \"text\": \"text = &message back& <>= \\\"\",\r\n      \"displayText\": \"displayText = &message back& <>= \\\"\",\r\n      \"value\": {\r\n        \"text\": \"some text 2\"\r\n      }\r\n    }\r\n  ]\r\n}",
      "name": null,
      "thumbnailUrl": null
    }
  ],
  "mentions": [],
  "reactions": [
    {
      "reactionType": "angry",
      "createdDateTime": "2018-10-21T08:10:30.489Z",
      "user": {
        "application": null,
        "device": null,
        "user": {
          "id": "f1b66449-b46d-49b0-9c3c-53c10a5c818e",
          "displayName": null,
          "userIdentityType": "aadUser"
        }
      }
    },
    {
      "reactionType": "laugh",
      "createdDateTime": "2018-10-21T08:10:32.489Z",
      "user": {
        "application": null,
        "device": null,
        "user": {
          "id": "03a02232-d8f5-4970-a77e-6e8c76ce7a4e",
          "displayName": null,
          "userIdentityType": "aadUser"
        }
      }
    },
    {
      "reactionType": "like",
      "createdDateTime": "2018-10-21T02:17:14.67Z",
      "user": {
        "application": null,
        "device": null,
        "user": {
          "id": "f1b66449-b46d-49b0-9c3c-53c10a5c818e",
          "displayName": null,
          "userIdentityType": "aadUser"
        }
      }
    },
    {
      "reactionType": "like",
      "createdDateTime": "2018-10-21T02:34:40.3Z",
      "user": {
        "application": null,
        "device": null,
        "user": {
          "id": "4c9041b7-449a-40f7-8855-56da239b9fd1",
          "displayName": null,
          "userIdentityType": "aadUser"
        }
      }
    },
    {
      "reactionType": "like",
      "createdDateTime": "2018-10-21T08:10:25.489Z",
      "user": {
        "application": null,
        "device": null,
        "user": {
          "id": "03a02232-d8f5-4970-a77e-6e8c76ce7a4e",
          "displayName": null,
          "userIdentityType": "aadUser"
        }
      }
    },
    {
      "reactionType": "heart",
      "createdDateTime": "2018-10-21T08:10:31.489Z",
      "user": {
        "application": null,
        "device": null,
        "user": {
          "id": "03a02232-d8f5-4970-a77e-6e8c76ce7a4e",
          "displayName": null,
          "userIdentityType": "aadUser"
        }
      }
    },
    {
      "reactionType": "sad",
      "createdDateTime": "2018-10-21T08:10:33.489Z",
      "user": {
        "application": null,
        "device": null,
        "user": {
          "id": "03a02232-d8f5-4970-a77e-6e8c76ce7a4e",
          "displayName": null,
          "userIdentityType": "aadUser"
        }
      }
    },
    {
      "reactionType": "surprised",
      "createdDateTime": "2018-10-21T08:10:34.489Z",
      "user": {
        "application": null,
        "device": null,
        "user": {
          "id": "03a02232-d8f5-4970-a77e-6e8c76ce7a4e",
          "displayName": null,
          "userIdentityType": "aadUser"
        }
      }
    }
  ],
  "messageHistory": [
    {
      "modifiedDateTime": "2018-10-21T08:10:30.489Z",
      "actions": "reactionAdded",
      "reaction": {
        "reactionType": "angry",
        "user": {
          "application": null,
          "device": null,
          "user": {
            "id": "f1b66449-b46d-49b0-9c3c-53c10a5c818e",
            "displayName": null,
            "userIdentityType": "aadUser"
          }
        }
      }
    },
    {
      "modifiedDateTime": "2018-10-21T08:10:32.489Z",
      "actions": "reactionAdded",
      "reaction": {
        "reactionType": "laugh",
        "user": {
          "application": null,
          "device": null,
          "user": {
            "id": "03a02232-d8f5-4970-a77e-6e8c76ce7a4e",
            "displayName": null,
            "userIdentityType": "aadUser"
          }
        }
      }
    },
    {
      "modifiedDateTime": "2018-10-21T02:17:14.67Z",
      "actions": "reactionAdded",
      "reaction": {
        "reactionType": "like",
        "user": {
          "application": null,
          "device": null,
          "user": {
            "id": "f1b66449-b46d-49b0-9c3c-53c10a5c818e",
            "displayName": null,
            "userIdentityType": "aadUser"
          }
        }
      }
    },
    {
      "modifiedDateTime": "2018-10-21T02:34:40.3Z",
      "actions": "reactionAdded",
      "reaction": {
        "reactionType": "like",
        "user": {
          "application": null,
          "device": null,
          "user": {
            "id": "4c9041b7-449a-40f7-8855-56da239b9fd1",
            "displayName": null,
            "userIdentityType": "aadUser"
          }
        }
      }
    },
    {
      "modifiedDateTime": "2018-10-21T08:10:25.489Z",
      "actions": "reactionAdded",
      "reaction": {
        "reactionType": "like",
        "user": {
          "application": null,
          "device": null,
          "user": {
            "id": "03a02232-d8f5-4970-a77e-6e8c76ce7a4e",
            "displayName": null,
            "userIdentityType": "aadUser"
          }
        }
      }
    },
    {
      "modifiedDateTime": "2018-10-21T08:10:31.489Z",
      "actions": "reactionAdded",
      "reaction": {
        "reactionType": "heart",
        "user": {
          "application": null,
          "device": null,
          "user": {
            "id": "03a02232-d8f5-4970-a77e-6e8c76ce7a4e",
            "displayName": null,
            "userIdentityType": "aadUser"
          }
        }
      }
    },
    {
      "modifiedDateTime": "2018-10-21T08:10:33.489Z",
      "actions": "reactionAdded",
      "reaction": {
        "reactionType": "sad",
        "user": {
          "application": null,
          "device": null,
          "user": {
            "id": "03a02232-d8f5-4970-a77e-6e8c76ce7a4e",
            "displayName": null,
            "userIdentityType": "aadUser"
          }
        }
      }
    },
    {
      "modifiedDateTime": "2018-10-21T08:10:34.489Z",
      "actions": "surprised",
      "reaction": {
        "reactionType": "sad",
        "user": {
          "application": null,
          "device": null,
          "user": {
            "id": "03a02232-d8f5-4970-a77e-6e8c76ce7a4e",
            "displayName": null,
            "userIdentityType": "aadUser"
          }
        }
      }
    }
  ]
}

Отклик

Ниже приводится пример отклика.

HTTP/1.1 204 NoContent