在频道中向邮件发送答复

命名空间:microsoft.graph

向指定频道中的 chatMessage 发送新回复。

注意:

  • 建议不要通过标准创建消息流使用此 API 进行数据迁移。 对于数据迁移方案,请改用 导入消息 流。
  • 将 Microsoft Teams 用作日志文件违反了 使用条款 。 仅发送人们将阅读的消息。

此 API 可用于以下国家级云部署。

全局服务 美国政府 L4 美国政府 L5 (DOD) 由世纪互联运营的中国
✅ ✅ ✅ ✅

权限

为此 API 选择标记为最低特权的权限。 只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。

权限类型 最低特权权限 更高特权权限
委派(工作或学校帐户) ChannelMessage.Send Group.ReadWrite.All
委派(个人 Microsoft 帐户) 不支持。 不支持。
应用程序 Teamwork.Migrate.All 不可用。

注意

  • 仅支持向后兼容 Group.ReadWrite.All 权限。 建议更新解决方案,以使用上表中列出的替代权限,并避免今后使用这些权限。
  • 仅支持 迁移应用程序权限。 将来,Microsoft 可能要求你或你的客户根据导入的数据量支付其他费用。

HTTP 请求

POST /teams/{team-id}/channels/{channel-id}/messages/{message-id}/replies

请求标头

名称 类型 说明
Authorization string 持有者 {token}。 必填。 详细了解 身份验证和授权。

请求正文

在请求正文中,提供 消息 对象的 JSON 表示形式。 只有 body 属性是必需的。 其他属性是可选的。

响应

如果成功,此方法返回 201 Created 包含已创建 消息 的响应代码。

示例

示例 1:向 chatMessage 发送新回复

有关更全面的示例列表,请参阅 在频道或聊天中创建 chatMessage。

请求

以下示例显示了一个请求。

POST https://graph.microsoft.com/v1.0/teams/fbe2bf47-16c8-47cf-b4a5-4b9b187c508b/channels/19:4a95f7d8db4c4e7fae857bcebe0623e6@thread.tacv2/messages/1616990032035/replies
Content-type: application/json

{
  "body": {
    "contentType": "html",
    "content": "Hello World"
  }
}

响应

以下示例显示了相应的响应。

HTTP/1.1 201 Created
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('fbe2bf47-16c8-47cf-b4a5-4b9b187c508b')/channels('19%3A4a95f7d8db4c4e7fae857bcebe0623e6%40thread.tacv2')/messages('1616990032035')/replies/$entity",
    "id": "1616990171266",
    "replyToId": "1616990032035",
    "etag": "1616990171266",
    "messageType": "message",
    "createdDateTime": "2021-03-29T03:56:11.266Z",
    "lastModifiedDateTime": "2021-03-29T03:56:11.266Z",
    "lastEditedDateTime": null,
    "deletedDateTime": null,
    "subject": null,
    "summary": null,
    "chatId": null,
    "importance": "normal",
    "locale": "en-us",
    "webUrl": "https://teams.microsoft.com/l/message/19%3A4a95f7d8db4c4e7fae857bcebe0623e6%40thread.tacv2/1616990171266?groupId=fbe2bf47-16c8-47cf-b4a5-4b9b187c508b&tenantId=2432b57b-0abd-43db-aa7b-16eadd115d34&createdTime=1616990171266&parentMessageId=1616990032035",
    "policyViolation": null,
    "eventDetail": null,
    "from": {
        "application": null,
        "device": null,
        "user": {
            "@odata.type": "#microsoft.graph.teamworkUserIdentity",
            "id": "8ea0e38b-efb3-4757-924a-5f94061cf8c2",
            "displayName": "Robin Kline",
            "userIdentityType": "aadUser",
            "tenantId": "e61ef81e-8bd8-476a-92e8-4a62f8426fca"
        }
    },
    "body": {
        "contentType": "text",
        "content": "Hello World"
    },
    "channelIdentity": {
        "teamId": "fbe2bf47-16c8-47cf-b4a5-4b9b187c508b",
        "channelId": "19:4a95f7d8db4c4e7fae857bcebe0623e6@thread.tacv2"
    },
    "attachments": [],
    "mentions": [],
    "reactions": [],
    "messageHistory": []
}

示例 2:导入消息

以下示例演示如何导入消息回复。 有关详细信息,请参阅 使用 Microsoft Graph 将消息导入Microsoft Teams 聊天和频道。

注意:此方案需要权限范围 Teamwork.Migrate.All 。

重要

createdDateTime 在目标通道内必须唯一到毫秒。 如果存在具有相同 createdDateTime 的消息,则请求失败并出现 409 Conflict。 调整 createdDateTime 并重试。 有关详细信息,请参阅 使用 Microsoft Graph 将消息导入Microsoft Teams 聊天和频道。

请求

以下示例演示如何在 createDateTime 请求正文中使用 和 from 键导入实时消息。

POST https://graph.microsoft.com/v1.0/teams/57fb72d0-d811-46f4-8947-305e6072eaa5/channels/19:4b6bed8d24574f6a9e436813cb2617d8@thread.tacv2/messages/1590776551682/replies

{
   "createdDateTime":"2019-02-04T19:58:15.511Z",
   "from":{
      "user":{
         "id":"8c0a1a67-50ce-4114-bb6c-da9c5dbcf6ca",
         "displayName":"John Doe"
      }
   },
   "body":{
      "contentType":"html",
      "content":"Hello World"
   }
}

响应

以下示例显示了相应的响应。

HTTP/1.1 200 OK

{
   "@odata.context":"https://graph.microsoft.com/v1.0/$metadata#teams('57fb72d0-d811-46f4-8947-305e6072eaa5')/channels('19:4b6bed8d24574f6a9e436813cb2617d8@thread.tacv2')/messages('1590776551682')/replies/$entity",
   "id":"1591039710682",
   "replyToId":"1590776551682",
   "etag":"1591039710682",
   "messageType":"message",
   "createdDateTime":"2019-02-04T19:58:15.511Z",
   "lastModifiedDateTime":null,
   "deleted":false,
   "subject":null,
   "summary":null,
   "importance":"normal",
   "locale":"en-us",
   "policyViolation":null,
   "eventDetail": null,
   "from":{
      "application":null,
      "device":null,
      "user":{
         "@odata.type": "#microsoft.graph.teamworkUserIdentity",
         "id":"8c0a1a67-50ce-4114-bb6c-da9c5dbcf6ca",
         "displayName":"Joh Doe",
         "userIdentityType":"aadUser",
         "tenantId": "e61ef81e-8bd8-476a-92e8-4a62f8426fca"
      }
   },
   "body":{
      "contentType":"html",
      "content":"Hello World"
   },
   "attachments":[],
   "mentions":[],
   "reactions":[],
   "messageHistory": []
}