从群组API和/Conversations
端点,您可以获得会话列表,在查看群组应用时,您可以看到具有图片的用户。
但是从API返回的数据没有任何好的数据可用于用户查找。
我希望至少有一个电子邮件地址,而不仅仅是一个远非唯一的名字。是否有一种有效的方法来让用户无需遍历所有线程和帖子?
来自API的数据:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups('{id}')/threads",
"value": [{
"id": "{id}",
"topic": "Test main thread",
"hasAttachments": false,
"lastDeliveredDateTime": "2017-10-20T11:35:04Z",
"uniqueSenders": [
"Jonas Stensved"
],
"preview": "{message preview content}",
"isLocked": false
},
{
"id": "{id}",
"topic": "The new Test group is ready",
"hasAttachments": false,
"lastDeliveredDateTime": "2017-10-13T10:33:03Z",
"uniqueSenders": [
"Test"
],
"preview": "{message preview content}",
"isLocked": false
}
]
}
群组应用中的群组如何显示:
[]
答案 0 :(得分:1)
这里可能有助于细分对象层次结构:
Group
- 对话资源集合的父级Conversation
- 线程资源集合的父级Thread
- 父资源到邮政资源的集合Post
- 用户发送给该组的实际内容为了查看哪个User
资源映射到给定的Thread
,您需要向下钻取另一个级别以查找Thread中包含的Post
资源。
您可以使用$expand=posts
参数扩展Posts
集合。您还可以($select=from)
$expand
,这样您只需返回映射回User
资源所需的属性。
所以这个查询:
/v1.0/groups/{group-id}/threads?$expand=posts($select=from)
将为您提供Thread
这样的结果:
{
"id": "{thread-id}",
"topic": "New Training Plans",
"hasAttachments": false,
"lastDeliveredDateTime": "2017-07-31T18:59:05Z",
"uniqueSenders": [
"HR Taskforce"
],
"preview": "{thread-preview}",
"isLocked": false,
"posts@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups('{group-id}')/threads('{thread-id}')/posts(from)",
"posts": [{
"@odata.etag": "W/\"CwAAABYAAADE9kXbLjqkSJUGeLzs6eumAAAAAA0/\"",
"id": "{post-id}",
"changeKey": "CwAAABYAAADE9kXbLjqkSJUGeLzs6eumAAAAAA0/",
"from": {
"emailAddress": {
"name": "HR Taskforce",
"address": "HRTaskforce@M365x214355.onmicrosoft.com"
}
}
}]
}
您可以使用this Graph Explorer example自行尝试。
答案 1 :(得分:0)
您可以获取组成员列表并对其进行迭代。根据组的大小,这可能需要分页。您可以在文档中找到更多信息:https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/group
我希望这会有所帮助。