这个问题一般是 Adaptive card 中添加的 API 请求返回错误或超时导致的。解决方式是在请求 API 之前先检查网络连接是否正常,若正常则发起请求。若请求超时或返回错误,则显示相应的错误信息,例如:“网络请求超时”、“请求失败,请稍后再试”等。代码示例:
{
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Sample Adaptive Card"
},
{
"type": "Input.Text",
"id": "url",
"placeholder": "请输入 URL",
"validation": {
"necessity": "required",
"errorMessage": "URL 不能为空"
}
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.Http",
"id": "getData",
"method": "GET",
"url": "${url}",
"title": "获取数据",
"headers": {
"User-Agent": "Mozilla/5.0",
"Accept": "application/json"
},
"style": "positive",
"body": {
"key1": "value1",
"key2": "value2"
},
"onSuccess": [
{
"type": "Action.ShowCard",
"title": "成功提示",
"card": {
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "请求成功"
}
]
}
}
],
"onFailure": [
{
"type": "Action.ShowCard",
"title": "错误提示",
"card": {
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "网络请求失败"
}
]
}
}
],
"onTimeout": [
{
"type": "Action.ShowCard",
"title": "错误提示",
"card": {
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "网络请求超时"
}
]
}
}
]
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}