chat: getAllRetainedMessages

命名空间:microsoft.graph

从用户参与的所有聊天中获取所有保留的消息,包括一对一聊天、群组聊天和会议聊天。

要了解有关如何使用 Microsoft Teams 导出 API 来导出内容的详细信息,请参阅 使用 Microsoft Teams 导出 API 导出内容。

注意

此 API 需要配置 Teams 保留策略 。 有关详细信息,请参阅 了解 Microsoft Teams 的保留期。

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

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

权限

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

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

HTTP 请求

GET /users/{id}/chats/getAllRetainedMessages

可选的查询参数

此方法支持以下 OData 查询参数来帮助自定义响应。 若要了解一般信息,请参阅 OData 查询参数。

名称 说明
$filter $filter查询参数支持使用日期范围参数对 lastModifiedDateTime 属性进行日期和时间范围查询。
$top 使用 $top 查询参数控制每个响应的项目数。

以下示例演示了一个请求,该请求使用 $top 和 $filter 查询参数获取保留的聊天消息列表。

GET /users/{id}/chats/getAllRetainedMessages?$top=50&$filter=lastModifiedDateTime gt 2020-06-04T18:03:11.591Z and lastModifiedDateTime lt 2020-06-05T21:00:09.413Z

下表列出了演示如何使用 $filter 参数的示例。

应用场景 $filter 参数 可能的值
获取用户标识类型发送的消息 $filter=from/user/userIdentityType eq '{teamworkUserIdentityType}' aadUser, onPremiseAadUser, anonymousGuest, federatedUser, personalMicrosoftAccountUser, skypeUser, phoneUser
获取按应用程序类型发送的消息 $filter=from/application/applicationIdentityType eq '{teamworkApplicationIdentity}' aadApplication, bot, tenantBot, office365Connector, outgoingWebhook
获取用户 ID 发送的消息 $filter=from/user/id eq '{oid}'
获取控件 (系统事件) 消息 $filter=messageType eq 'systemEventMessage'
排除控件 (系统事件) 消息 $filter=messageType ne 'systemEventMessage'

请求标头

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

请求正文

请勿提供此方法的请求正文。

响应

如果成功,此方法在响应正文中返回 200 OK 响应代码和 chatMessage 对象集合。

示例

请求

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

GET https://graph.microsoft.com/v1.0/users/8b081ef6-4792-4def-b2c9-c363a1bf41d5/chats/getAllRetainedMessages

响应

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

注意:为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 200 OK
Content-type: application/json

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(chatMessage)",
  "@odata.count": 10,
  "@odata.nextLink": "https://graph.microsoft.com/v1.0/users/8b081ef6-4792-4def-b2c9-c363a1bf41d5/chats/getAllRetainedMessages?$skip=10",
  "value": [
    {
      "@odata.type": "#microsoft.graph.chatMessage",
      "id": "1600457965467",
      "replyToId": null,
      "etag": "1600457965467",
      "messageType": "message",
      "createdDateTime": "2020-09-18T19:39:25.467Z",
      "lastModifiedDateTime": "2020-09-18T19:39:25.467Z",
      "lastEditedDateTime": null,
      "deletedDateTime": null,
      "subject": null,
      "summary": null,
      "chatId": "19:0de69e5e-2da8-4cf2-821f-5e6585b2c65b_5c64e248-3269-4268-a36e-0f80314e9c39@unq.gbl.spaces",
      "importance": "normal",
      "locale": "en-us",
      "webUrl": null,
      "channelIdentity": null,
      "policyViolation": null,
      "eventDetail": null,
      "from": {
        "application": null,
        "device": null,
        "conversation": null,
        "user": {
          "id": "0de69e5e-2da8-4cf2-821f-5e6585b2c65b",
          "displayName": "Richard Wilson",
          "userIdentityType": "aadUser"
        }
      },
      "body": {
        "contentType": "html",
        "content": "<div>\n<blockquote itemscope=\"\" itemtype=\"http://schema.skype.com/Reply\" itemid=\"1600457867820\">\n<strong itemprop=\"mri\" itemid=\"8:orgid:0de69e5e-2da8-4cf2-821f-5e6585b2c65b\">Richard Wilson</strong><span itemprop=\"time\" itemid=\"1600457867820\"></span>\n<p itemprop=\"preview\">1237</p>\n</blockquote>\n<p>this is a reply</p>\n</div>"
      },
      "attachments": [],
      "mentions": [],
      "reactions": []
    }
  ]
}

Microsoft Graph 特定于服务的节流限制