你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Chat - Create Chat Thread
创建聊天线程。
POST {endpoint}/chat/threads?api-version=2024-03-07
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
endpoint
|
path | True |
string |
Azure 通信资源的终结点。 |
api-version
|
query | True |
string |
要调用的 API 版本。 |
请求头
名称 | 必需 | 类型 | 说明 |
---|---|---|---|
Authorization | True |
string |
ACS(Azure 通信服务)用户访问令牌。 |
repeatability-request-id |
string |
如果指定,客户端将指示请求可重复;也就是说,客户端可以使用相同的可重复性-Request-Id 多次发出请求并返回适当的响应,而无需服务器多次执行请求。 Repeatability-Request-Id 的值是一个不透明的字符串,表示客户端生成、全局唯一的、请求的标识符。 建议使用版本 4(随机)UUID。 |
请求正文
名称 | 必需 | 类型 | 说明 |
---|---|---|---|
topic | True |
string |
聊天线程主题。 |
participants |
要添加到聊天线程中的参与者。 |
响应
名称 | 类型 | 说明 |
---|---|---|
201 Created |
创建线程时, |
|
401 Unauthorized |
Communication |
未经 授权。 |
403 Forbidden |
Communication |
禁止。 |
429 Too Many Requests |
Communication |
请求过多。 |
Other Status Codes |
Communication |
服务不可用。 |
安全性
Authorization
ACS(Azure 通信服务)用户访问令牌。
类型:
apiKey
在:
header
示例
Create chat thread |
Create chat thread with repeatability request id header |
Create chat thread
示例请求
POST https://contoso.westus.communications.azure.com/chat/threads?api-version=2024-03-07
{
"topic": "Lunch",
"participants": [
{
"communicationIdentifier": {
"rawId": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_c94ff260-162d-46d6-94fd-e79f4d213715",
"communicationUser": {
"id": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_c94ff260-162d-46d6-94fd-e79f4d213715"
}
},
"displayName": "Jane"
},
{
"communicationIdentifier": {
"rawId": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_0e59221d-0c1d-46ae-9544-c963ce56c10b",
"communicationUser": {
"id": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_0e59221d-0c1d-46ae-9544-c963ce56c10b"
}
},
"displayName": "Alex"
},
{
"communicationIdentifier": {
"rawId": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_a34d2d65-d72f-4c48-a12c-2d5c9ac75a1a",
"communicationUser": {
"id": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_a34d2d65-d72f-4c48-a12c-2d5c9ac75a1a"
}
},
"displayName": "Bob"
},
{
"communicationIdentifier": {
"rawId": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_f6762773-e33a-4727-985f-50bd1d197c7b",
"communicationUser": {
"id": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_f6762773-e33a-4727-985f-50bd1d197c7b"
}
},
"displayName": "Peter"
}
]
}
示例响应
Location: https://contoso.westus.communications.azure.com/chat/threads/19%3Auni01_zbnh3nt2dfuffezc3sox7dog7wfhk6y5qe2rwlnfhlhdzirihdpq@thread.v2
{
"chatThread": {
"id": "19:uni01_zbnh3nt2dfuffezc3sox7dog7wfhk6y5qe2rwlnfhlhdzirihdpq@thread.v2",
"topic": "Lunch",
"createdOn": "2020-06-06T05:55:41.6460000Z",
"createdByCommunicationIdentifier": {
"rawId": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_c94ff260-162d-46d6-94fd-e79f4d213715",
"communicationUser": {
"id": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_c94ff260-162d-46d6-94fd-e79f4d213715"
}
}
},
"invalidParticipants": [
{
"target": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_a34d2d65-d72f-4c48-a12c-2d5c9ac75a1a",
"code": "403",
"message": "Permissions check failed"
},
{
"target": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_f6762773-e33a-4727-985f-50bd1d197c7b",
"code": "404",
"message": "Not found"
}
]
}
{
"error": {
"code": "Unauthorized",
"message": "Request is not authorized."
}
}
{
"error": {
"code": "Forbidden",
"message": "User is not allowed to perform specified action."
}
}
{
"error": {
"code": "TooManyRequests",
"message": "Rate limit exceeded."
}
}
{
"error": {
"code": "ServiceUnavailable",
"message": "The server is currently unable to handle the request."
}
}
Create chat thread with repeatability request id header
示例请求
POST https://contoso.westus.communications.azure.com/chat/threads?api-version=2024-03-07
{
"topic": "Lunch",
"participants": [
{
"communicationIdentifier": {
"rawId": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_c94ff260-162d-46d6-94fd-e79f4d213715",
"communicationUser": {
"id": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_c94ff260-162d-46d6-94fd-e79f4d213715"
}
},
"displayName": "Jane"
},
{
"communicationIdentifier": {
"rawId": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_0e59221d-0c1d-46ae-9544-c963ce56c10b",
"communicationUser": {
"id": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_0e59221d-0c1d-46ae-9544-c963ce56c10b"
}
},
"displayName": "Alex"
},
{
"communicationIdentifier": {
"rawId": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_a34d2d65-d72f-4c48-a12c-2d5c9ac75a1a",
"communicationUser": {
"id": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_a34d2d65-d72f-4c48-a12c-2d5c9ac75a1a"
}
},
"displayName": "Bob"
},
{
"communicationIdentifier": {
"rawId": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_f6762773-e33a-4727-985f-50bd1d197c7b",
"communicationUser": {
"id": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_f6762773-e33a-4727-985f-50bd1d197c7b"
}
},
"displayName": "Peter"
}
]
}
示例响应
Location: https://contoso.westus.communications.azure.com/chat/threads/19%3Auni01_zbnh3nt2dfuffezc3sox7dog7wfhk6y5qe2rwlnfhlhdzirihdpq@thread.v2
{
"chatThread": {
"id": "19:uni01_zbnh3nt2dfuffezc3sox7dog7wfhk6y5qe2rwlnfhlhdzirihdpq@thread.v2",
"topic": "Lunch",
"createdOn": "2020-06-06T05:55:41.6460000Z",
"createdByCommunicationIdentifier": {
"rawId": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_c94ff260-162d-46d6-94fd-e79f4d213715",
"communicationUser": {
"id": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_c94ff260-162d-46d6-94fd-e79f4d213715"
}
}
},
"invalidParticipants": [
{
"target": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_a34d2d65-d72f-4c48-a12c-2d5c9ac75a1a",
"code": "403",
"message": "Permissions check failed"
},
{
"target": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_f6762773-e33a-4727-985f-50bd1d197c7b",
"code": "404",
"message": "Not found"
}
]
}
{
"error": {
"code": "Unauthorized",
"message": "Request is not authorized."
}
}
{
"error": {
"code": "Forbidden",
"message": "User is not allowed to perform specified action."
}
}
{
"error": {
"code": "TooManyRequests",
"message": "Rate limit exceeded."
}
}
{
"error": {
"code": "ServiceUnavailable",
"message": "The server is currently unable to handle the request."
}
}
定义
名称 | 说明 |
---|---|
Chat |
聊天线程的参与者。 |
Chat |
聊天线程。 |
Create |
请求用于创建聊天线程的有效负载。 |
Create |
创建聊天线程操作的结果。 |
ChatParticipant
聊天线程的参与者。
名称 | 类型 | 说明 |
---|---|---|
communicationIdentifier |
Communication |
|
displayName |
string |
聊天参与者的显示名称。 |
shareHistoryTime |
string |
聊天历史记录与参与者共享的时间。 时间戳采用RFC3339格式: |
ChatThreadProperties
聊天线程。
名称 | 类型 | 说明 |
---|---|---|
createdByCommunicationIdentifier |
Communication |
|
createdOn |
string |
创建聊天线程时的时间戳。 时间戳采用RFC3339格式: |
deletedOn |
string |
删除聊天线程时的时间戳。 时间戳采用RFC3339格式: |
id |
string |
聊天线程 ID。 |
topic |
string |
聊天线程主题。 |
CreateChatThreadRequest
请求用于创建聊天线程的有效负载。
名称 | 类型 | 说明 |
---|---|---|
participants |
要添加到聊天线程中的参与者。 |
|
topic |
string |
聊天线程主题。 |
CreateChatThreadResult
创建聊天线程操作的结果。
名称 | 类型 | 说明 |
---|---|---|
chatThread |
聊天线程。 |
|
invalidParticipants |
Communication |
未能添加到聊天线程的参与者。 |