1

当我向最重要的 API 发送请求时。我收到响应错误代码 400(错误请求)。 我正在使用 c# 的语言,并且这个序列化一个匿名类来生成格式。

{ 
    "trigger_id":
         "a2k0eGhveDN3M2dtN2I0Y3c3b3BobXBoZW86bXlubmk3eGg4M2Y3eDhoMThucjE0c3dvb3I6MTU1NTk1MTg3NjAxNjpNRVFDSUU4VDFqYmNSVGswdDZRQVVFU3haZk5URTg3MUhMT1ozK003aWdsQ01nckhBaUFac290SncwMmFSSkRWNEQyTFN0eXpGY0QySFREeVI2SVg3clY3ejVlMjFnPT0=",
               "url": "https://myapi.com/api/values/service",
               "dialog": {
                 "callback_id": "123",
                 "title": "Form Test",
                 "icon_url": "http://www.mattermost.org/wp-content/uploads/2016/04/icon.png",
                 "elements": [
                   {
                     "display_name": "Display Name",
                     "name": "Name",
                     "type": "text",
                    "subtype": "",
                     "default": "default text",
                    "placeholder": "Placeholder",
                    "help_text": "This is a test regular input",
                    "optional": false,
                     "min_length": 0,
                     "max_length": 0,
                    "data_source": "",
                    "options": null
                  },
                   {
                    "display_name": "Email",
                     "name": "youremail@email.com",
                     "type": "text",
                     "subtype": "",
                    "default": "default text",
                     "placeholder": "placeholder@bladekick.com",
                     "help_text": "This is a test regular input",
                 "optional": false,
                  "min_length": 0,
                     "max_length": 0,
                     "data_source": "",
                   "options": null
                  },
                   {
                    "display_name": "Number",
                     "name": "Number",
                     "type": "text",
                     "subtype": "number",
                     "default": "",
                     "placeholder": "",
                     "help_text": "",
                     "optional": false,
                     "min_length": 0,
                     "max_length": 0,
                     "data_source": "",
                     "options": null
                   }
                 ],
                 "submit_label": "Enviar",
                 "notify_on_cancel": false,
                 "state": "Default state"
        }
    }

这是我发送的 json,请 帮助我解决此错误。 附件图片 代码 400

4

1 回答 1

0

嗯,我解决了。我的错误是我发出 HTTP 请求的方式。

我正在做的事情延迟了请求并且“trigger_id”过期了。请记住,“trigger_id”的使用寿命为 3 秒。

我的建议是尝试使用不同的方式发送请求,因为我发送的 JSON(与您的相同)是正确的。我的另一个观察是,它显然没有将其作为“应用程序/json”正确发送</p>

于 2019-04-24T20:28:24.743 回答