使用 Microsoft Teams 时发布到 Microsoft Connector Service 时出现未分类错误
Unclassified Error when posting to Microsoft Connector Service when using Microsoft Teams
当我在收到来自 Microsoft 团队的消息后 post 到连接器服务时,我在 body 中收到了 404 响应。
{"error":{"code":"Unclassified","message":""}}
该服务与 Skype 合作,并且在大约 10 天前与团队合作。
我已经尝试了 ReplyToActivity 和 RespondToConversation 端点。我还尝试在 conversation.id.
中编码 :
代码可以看这里:https://github.com/Grungnie/microsoftbotframework/blob/FixTeamsError732/microsoftbotframework/response.py在方法reply_to_activity.
从 Microsoft 收到的消息(id 标记略有变化)
{
"text": "Test Message",
"textFormat": "plain",
"type": "message",
"timestamp": "2017-03-27T11:55:33.983Z",
"id": "1490615736123",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/apac-client-ss.msg/",
"from": {
"id": "29:10U0pO0yzCqc_TZQImyaX1JGhe9KWpagDIwqtTl0moeT2lNC4PMrm9B2W_0w-Cr9tr5rty8vEZErb4yoyautked",
"name": "Matthew Brown"
},
"conversation": {
"id": "a:1lRzVTZeip__5jthfxCqiWX8koXTOg5OsFsnefe2kesHxvJAcJxNJs-TT3NvR1ote1PZZ_DQVkd5u5wsKmw2TQy53bvXOlXydDJjUUcolfphZWu2N-HuX8181rfRIMj7Q"
},
"recipient": {
"id": "28:5e21d7a8-d1b5-4534-f549-f521712f5a64",
"name": "PythonBotFramework"
},
"entities": [
{
"locale": "en-AU",
"country": "AU",
"platform": "Android",
"type": "clientInfo"
}
],
"channelData": {
"tenant": {
"id": "5ghtef8a-55a8-4263-bd84-e03688a2ab2d"
}
}
}
Headers
Host: microsoftbotframework.herokuapp.com
Connection: close
Contextid: tcid=5448949784053522007, server=EAP010254248242
Authorization: Bearer eyJ0eXAiOiJ....
User-Agent: Microsoft-SkypeBotApi (Microsoft-BotFramework/3.0)
Content-Type: application/json; charset=utf-8
X-Request-Id: 6d8510c4-e3ba-4e34-80b2-45305a38d022
X-Forwarded-For: 13.75.95.64
X-Forwarded-Proto: https
X-Forwarded-Port: 443
Via: 1.1 vegur
Connect-Time: 0
X-Request-Start: 1490615736123
Total-Route-Time: 0
Content-Length: 747
我的回复
URL
https://smba.trafficmanager.net/v3/conversations/a:1lRzVTZeip__5jthfxCqiWX8koXTOg5OsFsnefe2kesHxvJAcJxNJs-TT3NvR1ote1PZZ_DQVkd5u5wsKmw2TQy53bvXOlXydDJjUUcolfphZWu2N-HuX8181rfRIMj7Q/activities/1490615736123
Headers
Authorization: Bearer eyJ0eXAgibJ....
Body
{
"from": {
"id": "28:5e21d7a8-d1b5-4534-f549-f521712f5a64",
"name": "PythonBotFramework"
},
"type": "message",
"timestamp": "2017-03-27T11:55:36.463971Z",
"conversation": {
"id": "a:1lRzVTZeip__5jthfxCqiWX8koXTOg5OsFsnefe2kesHxvJAcJxNJs-TT3NvR1ote1PZZ_DQVkd5u5wsKmw2TQy53bvXOlXydDJjUUcolfphZWu2N-HuX8181rfRIMj7Q"
},
"recipient": {
"id": "29:10U0pO0yzCqc_TZQImyaX1JGhe9KWpagDIwqtTl0moeT2lNC4PMrm9B2W_0w-Cr9tr5rty8vEZErb4yoyautked",
"name": "Matthew BROWN"
},
"text": "How bout no",
"replyToId": "1490615736123",
"serviceUrl": "https://smba.trafficmanager.net/apac-client-ss.msg/",
"channelId": "msteams",
"channelData": {
"tenant": {
"id": "5ghtef8a-55a8-4263-bd84-e03688a2ab2d"
}
},
"textFormat": "plain"
}
** 29/3 错误代码更改后更新。之前的错误代码如下。
{"errorCode":732,"message":""}
所以我弄错了,
response_url = urljoin(self["serviceUrl"], "/v3/conversations/{}/activities/{}".format( conversation_id, reply_to_id))
urljoin 正在剥离 self["serviceUrl"] 的 url 的最后一部分。这是预期的行为。似乎没有一种方法可以将 url 的两个部分连接在一起。我想这样做是因为微软有时会发送以“/”结尾的 url,有时则不会。我想我会写我自己的方法。
当我在收到来自 Microsoft 团队的消息后 post 到连接器服务时,我在 body 中收到了 404 响应。
{"error":{"code":"Unclassified","message":""}}
该服务与 Skype 合作,并且在大约 10 天前与团队合作。
我已经尝试了 ReplyToActivity 和 RespondToConversation 端点。我还尝试在 conversation.id.
中编码 :代码可以看这里:https://github.com/Grungnie/microsoftbotframework/blob/FixTeamsError732/microsoftbotframework/response.py在方法reply_to_activity.
从 Microsoft 收到的消息(id 标记略有变化)
{
"text": "Test Message",
"textFormat": "plain",
"type": "message",
"timestamp": "2017-03-27T11:55:33.983Z",
"id": "1490615736123",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/apac-client-ss.msg/",
"from": {
"id": "29:10U0pO0yzCqc_TZQImyaX1JGhe9KWpagDIwqtTl0moeT2lNC4PMrm9B2W_0w-Cr9tr5rty8vEZErb4yoyautked",
"name": "Matthew Brown"
},
"conversation": {
"id": "a:1lRzVTZeip__5jthfxCqiWX8koXTOg5OsFsnefe2kesHxvJAcJxNJs-TT3NvR1ote1PZZ_DQVkd5u5wsKmw2TQy53bvXOlXydDJjUUcolfphZWu2N-HuX8181rfRIMj7Q"
},
"recipient": {
"id": "28:5e21d7a8-d1b5-4534-f549-f521712f5a64",
"name": "PythonBotFramework"
},
"entities": [
{
"locale": "en-AU",
"country": "AU",
"platform": "Android",
"type": "clientInfo"
}
],
"channelData": {
"tenant": {
"id": "5ghtef8a-55a8-4263-bd84-e03688a2ab2d"
}
}
}
Headers
Host: microsoftbotframework.herokuapp.com
Connection: close
Contextid: tcid=5448949784053522007, server=EAP010254248242
Authorization: Bearer eyJ0eXAiOiJ....
User-Agent: Microsoft-SkypeBotApi (Microsoft-BotFramework/3.0)
Content-Type: application/json; charset=utf-8
X-Request-Id: 6d8510c4-e3ba-4e34-80b2-45305a38d022
X-Forwarded-For: 13.75.95.64
X-Forwarded-Proto: https
X-Forwarded-Port: 443
Via: 1.1 vegur
Connect-Time: 0
X-Request-Start: 1490615736123
Total-Route-Time: 0
Content-Length: 747
我的回复 URL
https://smba.trafficmanager.net/v3/conversations/a:1lRzVTZeip__5jthfxCqiWX8koXTOg5OsFsnefe2kesHxvJAcJxNJs-TT3NvR1ote1PZZ_DQVkd5u5wsKmw2TQy53bvXOlXydDJjUUcolfphZWu2N-HuX8181rfRIMj7Q/activities/1490615736123
Headers
Authorization: Bearer eyJ0eXAgibJ....
Body
{
"from": {
"id": "28:5e21d7a8-d1b5-4534-f549-f521712f5a64",
"name": "PythonBotFramework"
},
"type": "message",
"timestamp": "2017-03-27T11:55:36.463971Z",
"conversation": {
"id": "a:1lRzVTZeip__5jthfxCqiWX8koXTOg5OsFsnefe2kesHxvJAcJxNJs-TT3NvR1ote1PZZ_DQVkd5u5wsKmw2TQy53bvXOlXydDJjUUcolfphZWu2N-HuX8181rfRIMj7Q"
},
"recipient": {
"id": "29:10U0pO0yzCqc_TZQImyaX1JGhe9KWpagDIwqtTl0moeT2lNC4PMrm9B2W_0w-Cr9tr5rty8vEZErb4yoyautked",
"name": "Matthew BROWN"
},
"text": "How bout no",
"replyToId": "1490615736123",
"serviceUrl": "https://smba.trafficmanager.net/apac-client-ss.msg/",
"channelId": "msteams",
"channelData": {
"tenant": {
"id": "5ghtef8a-55a8-4263-bd84-e03688a2ab2d"
}
},
"textFormat": "plain"
}
** 29/3 错误代码更改后更新。之前的错误代码如下。
{"errorCode":732,"message":""}
所以我弄错了,
response_url = urljoin(self["serviceUrl"], "/v3/conversations/{}/activities/{}".format( conversation_id, reply_to_id))
urljoin 正在剥离 self["serviceUrl"] 的 url 的最后一部分。这是预期的行为。似乎没有一种方法可以将 url 的两个部分连接在一起。我想这样做是因为微软有时会发送以“/”结尾的 url,有时则不会。我想我会写我自己的方法。