.net core 使用错误对象响应slack view_提交事件

.net core 使用错误对象响应slack view_提交事件,.net-core,asp.net-core-webapi,slack,slack-dialog,.net Core,Asp.net Core Webapi,Slack,Slack Dialog,我使用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" },

我使用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_提交事件,如果电话号码的格式无效,我会错误地响应此事件。 Slack docs说我应该用这样的json对象来响应:

`{
  "response_action": "errors",
  "errors": {
    "phone_number": "Invalid phone number format"
  }
}`
在调试过程中,我发现我的应用程序确实从文件中加载json,并使用包含此json的字符串进行响应。但是a仍然在我的模型上得到这个错误

控制器方法返回任务>对象,但我不确定它是否正确 所以我的问题是: 有人知道我应该如何使用.net内核响应此松弛事件吗?
据我所知,即使我的.net core应用程序中存在验证错误,并且我想将错误对象返回到slack,我也应该以状态200 OK进行响应。最后,通过返回,这个问题得到了解决

Content('json_string', "application/json");

虽然问题是针对ASP.NET的,但是如果您正在使用Django并来到这里寻求答案,那么您可以使用:return JsonResponse({“response_action”:“errors”,“errors”:{“phone_number”:“Invalid phone number format”})不要忘记导入:from Django.http导入JsonResponse