我使用ASP.NET Core 2.1与Slack建立集成这是我的json格式的模态。
{
"type": "modal",
"callback_id": "send_sms",
"title": {
"type": "plain_text",
"text": "Send SMS",
"emoji": false
},
"submit": {
"type": "plain_text",
"text": "Submit"
},
"close": {
"type": "plain_text",
"text": "Cancel"
},
"blocks": [
{
"type": "divider"
},
{
"type": "input",
"block_id": "phone_number",
"label": {
"type": "plain_text",
"text": "Enter phone number",
"emoji": false
},
"element": {
"type": "plain_text_input",
"placeholder": {
"type": "plain_text",
"text": "Phone number",
"emoji": false
},
"action_id": "action_phone_number"
}
},
{
"type": "input",
"block_id": "message",
"label": {
"type": "plain_text",
"text": "Enter message",
"emoji": false
},
"element": {
"placeholder": {
"type": "plain_text",
"text": "Message",
"emoji": false
},
"action_id": "message",
"type": "plain_text_input",
"multiline": true
}
}
]
}
因此,当用户提交表单时,我的.net核心应用程序会收到一个view_submission事件,如果电话号码的格式无效,我想对此事件做出响应并返回错误。松弛文档说我应该用这样的json对象来响应:
`{
"response_action": "errors",
"errors": {
"phone_number": "Invalid phone number format"
}
}`
[在调试过程中,我发现我的应用程序实际上确实从文件中加载json,并使用包含该json的字符串进行响应。但是仍然在我的模态上出现此错误enter image description here
控制器方法返回Task>对象,但我不确定它是否正确所以我的问题是:有人知道我应该如何使用.net core响应此松弛事件吗?据我了解,即使我的.net核心应用中出现验证错误,并且我想将错误对象返回到松弛状态,我也应该以状态200 OK进行响应
Content('json_string', "application/json");