聊天: getAllMessages
命名空间:microsoft.graph
从用户参与的所有 聊天 中获取所有 消息,包括一对一聊天、群组聊天和会议聊天。
注意:此 API 具有 许可和付款要求。 它支持
model=A和model=B查询参数。 如果未指定模型,将使用评估模式。
权限
以下权限需要调用此 API。要了解详细信息,包括如何选择权限,请参阅权限。
| 权限类型 | 权限(从最低特权到最高特权) |
|---|---|
| 委派(工作或学校帐户) | 不支持。 |
| 委派(个人 Microsoft 帐户) | 不支持。 |
| 应用程序 | Chat.Read.All、Chat.ReadWrite.All |
备注
在使用应用程序权限调用此 API 之前,必须先请求访问权限。 有关详细信息,请参阅 Microsoft Teams 中的受保护 API。
HTTP 请求
GET /users/{id | user-principal-name}/chats/getAllMessages
可选的查询参数
可以使用model查询参数,该参数支持基于首选许可和付款模式值A和B,如以下示例所示。
如果未指定 model,将使用 评估模式。
GET /users/{id | user-principal-name}/chats/getAllMessages?model=A
GET /users/{id | user-principal-name}/chats/getAllMessages?model=B
如果未指定 model,将使用 评估模式。
此操作还支持 日期范围参数来自定义响应,如下例所示。
GET /users/{id}/chats/getAllMessages?$top=50&$filter=lastModifiedDateTime gt 2020-06-04T18:03:11.591Z and lastModifiedDateTime lt 2020-06-05T21:00:09.413Z
请求标头
| 标头 | 值 |
|---|---|
| Authorization | Bearer {token}。必需。 |
响应
如果成功,此方法将在正文中返回 200 OK 响应代码和chatMessages 的列表。
示例
请求
GET https://graph.microsoft.com/v1.0/users/0b4f1cf6-54c8-4820-bbb7-2a1f4257ade5/chats/getAllMessages?$top=2
响应
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(chatMessage)",
"@odata.count": 2,
"@odata.nextLink": "https://graph.microsoft.com/v1.0/users('0b4f1cf6-54c8-4820-bbb7-2a1f4257ade5')/chats/getallMessages?$top=2&$skiptoken=U2tpcFZhbHVlPTIjTWFpbGJveEZvbGRlcj1NYWlsRm9sZGVycy9UZWFtc01lc3NhZ2VzRGF0YQ%3d%3d",
"value": [
{
"@odata.type": "#microsoft.graph.chatMessage",
"id": "1621973534864",
"replyToId": null,
"etag": "1621973534864",
"messageType": "message",
"createdDateTime": "2021-05-25T20:12:14.864Z",
"lastModifiedDateTime": "2021-05-25T20:12:14.864Z",
"lastEditedDateTime": null,
"deletedDateTime": null,
"subject": null,
"summary": null,
"chatId": "19:3c9e92a344704332bbf5bda58f4d37b1@thread.v2",
"importance": "normal",
"locale": "en-us",
"webUrl": null,
"channelIdentity": null,
"policyViolation": null,
"eventDetail": null,
"from": {
"application": null,
"device": null,
"user": {
"id": "0b4f1cf6-54c8-4820-bbb7-2a1f4257ade5",
"displayName": "user1 a",
"userIdentityType": "aadUser"
}
},
"body": {
"contentType": "text",
"content": "Hello user2, user 3"
},
"attachments": [],
"mentions": [],
"reactions": []
},
{
"@odata.type": "#microsoft.graph.chatMessage",
"id": "1622762567488",
"replyToId": null,
"etag": "1622762567488",
"messageType": "message",
"createdDateTime": "2021-06-03T23:22:47.488Z",
"lastModifiedDateTime": "2021-06-03T23:22:47.488Z",
"lastEditedDateTime": null,
"deletedDateTime": null,
"subject": null,
"summary": null,
"chatId": "19:0b4f1cf6-54c8-4820-bbb7-2a1f4257ade5_0d7c63d3-1306-4eec-8f21-588a70fb6ef1@unq.gbl.spaces",
"importance": "normal",
"locale": "en-us",
"webUrl": null,
"channelIdentity": null,
"policyViolation": null,
"eventDetail": null,
"from": {
"application": null,
"device": null,
"user": {
"id": "0b4f1cf6-54c8-4820-bbb7-2a1f4257ade5",
"displayName": "user1 a",
"userIdentityType": "aadUser"
}
},
"body": {
"contentType": "text",
"content": "hi user2"
},
"attachments": [],
"mentions": [],
"reactions": []
}
]
}
反馈
提交和查看相关反馈