命名空间:microsoft.graph
获取聊天中固定的ChatMessage 列表。
此 API 可用于以下国家级云部署。
| 全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
| ✅ |
✅ |
✅ |
✅ |
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
| 权限类型 |
最低特权权限 |
更高特权权限 |
| 委派(工作或学校帐户) |
Chat.Read |
Chat.ReadWrite |
| 委派(个人 Microsoft 帐户) |
不支持。 |
不支持。 |
| 应用程序 |
ChatMessage.Read.All |
Chat.ReadWrite.All、Chat.Read.All |
HTTP 请求
GET /chats/{chat-id}/pinnedMessages
可选的查询参数
此方法支持 $expandOData 查询参数 来帮助自定义响应。
| 名称 |
说明 |
| Authorization |
持有者 {token}。 必填。 详细了解 身份验证和授权。 |
请求正文
请勿提供此方法的请求正文。
响应
如果成功,此方法在 200 OK 响应正文中返回响应代码和 pinnedChatMessageInfo 对象的集合。
示例
示例 1:列出聊天中的所有固定消息
以下示例显示了一个列出聊天中所有固定消息的请求。
请求
以下示例显示了一个请求。
GET https://graph.microsoft.com/v1.0/chats/19:d65713bc498c4a428c71ef9353e6ce20@thread.v2/pinnedMessages
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://free.blessedness.top/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Chats["{chat-id}"].PinnedMessages.GetAsync();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://free.blessedness.top/en-us/graph/sdks/create-client?from=snippets&tabs=go
pinnedMessages, err := graphClient.Chats().ByChatId("chat-id").PinnedMessages().Get(context.Background(), nil)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
PinnedChatMessageInfoCollectionResponse result = graphClient.chats().byChatId("{chat-id}").pinnedMessages().get();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
let pinnedMessages = await client.api('/chats/19:d65713bc498c4a428c71ef9353e6ce20@thread.v2/pinnedMessages')
.get();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->chats()->byChatId('chat-id')->pinnedMessages()->get()->wait();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
# To initialize your graph_client, see https://free.blessedness.top/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.chats.by_chat_id('chat-id').pinned_messages.get()
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-Type: application/json
{
"value": [
{
"@odata.type": "#microsoft.graph.pinnedChatMessageInfo",
"id": "1616964509832"
},
{
"@odata.type": "#microsoft.graph.pinnedChatMessageInfo",
"id": "1615971548136"
}
]
}
示例 2:列出聊天中的所有固定消息以及关联的聊天消息
以下示例显示了一个请求,该请求列出聊天中的所有固定消息以及关联的聊天消息。
请求
以下示例显示了一个请求。
GET https://graph.microsoft.com/v1.0/chats/19:d65713bc498c4a428c71ef9353e6ce20@thread.v2/pinnedMessages?$expand=message
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://free.blessedness.top/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Chats["{chat-id}"].PinnedMessages.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Expand = new string []{ "message" };
});
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphchats "github.com/microsoftgraph/msgraph-sdk-go/chats"
//other-imports
)
requestParameters := &graphchats.ItemPinnedMessagesRequestBuilderGetQueryParameters{
Expand: [] string {"message"},
}
configuration := &graphchats.ItemPinnedMessagesRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://free.blessedness.top/en-us/graph/sdks/create-client?from=snippets&tabs=go
pinnedMessages, err := graphClient.Chats().ByChatId("chat-id").PinnedMessages().Get(context.Background(), configuration)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
PinnedChatMessageInfoCollectionResponse result = graphClient.chats().byChatId("{chat-id}").pinnedMessages().get(requestConfiguration -> {
requestConfiguration.queryParameters.expand = new String []{"message"};
});
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
let pinnedMessages = await client.api('/chats/19:d65713bc498c4a428c71ef9353e6ce20@thread.v2/pinnedMessages')
.expand('message')
.get();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Chats\Item\PinnedMessages\PinnedMessagesRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new PinnedMessagesRequestBuilderGetRequestConfiguration();
$queryParameters = PinnedMessagesRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->expand = ["message"];
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->chats()->byChatId('chat-id')->pinnedMessages()->get($requestConfiguration)->wait();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Teams
Get-MgChatPinnedMessage -ChatId $chatId -ExpandProperty "message"
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.chats.item.pinned_messages.pinned_messages_request_builder import PinnedMessagesRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://free.blessedness.top/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = PinnedMessagesRequestBuilder.PinnedMessagesRequestBuilderGetQueryParameters(
expand = ["message"],
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.chats.by_chat_id('chat-id').pinned_messages.get(request_configuration = request_configuration)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-Type: application/json
{
"value": [
{
"id": "1616964509832",
"message": {
"id": "1616964509832",
"replyToId": null,
"etag": "1616964509832",
"messageType": "message",
"createdDateTime": "2021-03-28T20:48:29.832Z",
"lastModifiedDateTime": "2021-03-28T20:48:29.832Z",
"lastEditedDateTime": null,
"deletedDateTime": null,
"subject": null,
"summary": null,
"chatId": "19:2da4c29f6d7041eca70b638b43d45437@thread.v2",
"importance": "normal",
"locale": "en-us",
"webUrl": null,
"channelIdentity": null,
"onBehalfOf": null,
"policyViolation": null,
"eventDetail": null,
"from": {
"application": null,
"device": null,
"user": {
"id": "8ea0e38b-efb3-4757-924a-5f94061cf8c2",
"displayName": "Robin Kline",
"userIdentityType": "aadUser"
}
},
"body": {
"contentType": "text",
"content": "Hello world"
},
"attachments": [],
"mentions": [],
"reactions": []
}
},
{
"id": "1615971548136",
"message": {
"id": "1615971548136",
"replyToId": null,
"etag": "1615971548136",
"messageType": "message",
"createdDateTime": "2021-03-17T08:59:08.136Z",
"lastModifiedDateTime": "2021-03-17T08:59:08.136Z",
"lastEditedDateTime": null,
"deletedDateTime": null,
"subject": null,
"summary": null,
"chatId": "19:2da4c29f6d7041eca70b638b43d45437@thread.v2",
"importance": "normal",
"locale": "en-us",
"webUrl": null,
"channelIdentity": null,
"onBehalfOf": null,
"policyViolation": null,
"eventDetail": null,
"from": {
"application": null,
"device": null,
"user": {
"id": "8ea0e38b-efb3-4757-924a-5f94061cf8c2",
"displayName": "Robin Kline",
"userIdentityType": "aadUser"
}
},
"body": {
"contentType": "html",
"content": "<div><div><div><span><img height=\"63\" src=\"https://graph.microsoft.com/v1.0/chats/19:2da4c29f6d7041eca70b638b43d45437@thread.v2/messages/1615971548136/hostedContents/aWQ9eF8wLXd1cy1kOS1lNTRmNjM1NWYxYmJkNGQ3ZTNmNGJhZmU4NTI5MTBmNix0eXBlPTEsdXJsPWh0dHBzOi8vdXMtYXBpLmFzbS5za3lwZS5jb20vdjEvb2JqZWN0cy8wLXd1cy1kOS1lNTRmNjM1NWYxYmJkNGQ3ZTNmNGJhZmU4NTI5MTBmNi92aWV3cy9pbWdv/$value\" width=\"67\" style=\"vertical-align:bottom; width:67px; height:63px\"></span></div></div></div>"
},
"attachments": [],
"mentions": [],
"reactions": []
}
}
]
}