Cannot open interactive dialog

Follow: https://docs.mattermost.com/developer/interactive-dialogs.html
When I post a json to URL: http://<mattermost_server>/api/v4/actions/dialogs/open
A dialog cannot open, it get response:

{“id”:“api.context.invalid_body_param.app_error”,“message”:“Invalid or missing dialog in request body”,“detailed_error”:"",“request_id”:“p7furam6m3b43fgcuit5b1ng7a”,“status_code”:400}

Who can tell me why this happens and what’s wrong with my posted json below

The json I post is:

{ "trigger_id": "cjRraGRhaG1tdHI4NXA0aHNvcWdpazk0bmg6ZnltZ3Joa2Zwam54M2tnbjl0dGE5ZDh4Z3k6MTU1NDU0MDY3NTUzMTpNRVlDSVFDcW1hdG0rSVZlc3hkcER5NkZzSmh5VWxLQk9RWEhycFRTUVNiU1JvQ3BzZ0loQUx4eTREc3hYUWx4TE82Rk1yL3g5bjA0YlJjRC9GQnY1Szd5VVFRVm9SYmk=", "url": "", "dialog": { "callback_id": "callid", "title": "dialog title", "elements": [ { "display_name": "Email", "name": "email", "type": "text" } ] } }

Hi @WJ.CAI, what Mattermost server version are you on?

I am using mattermost community 5.8 & 5.9
Both version do not work

@WJ.CAI Can you help share the HTTP POST request you send to the API? (you can sanitize sensitive parameters)

the request is:
POST http://<mattermost_server>/api/v4/actions/dialogs/open

{
	"trigger_id": "cjRraGRhaG1tdHI4NXA0aHNvcWdpazk0bmg6ZnltZ3Joa2Zwam54M2tnbjl0dGE5ZDh4Z3k6MTU1NDU0MDY3NTUzMTpNRVlDSVFDcW1hdG0rSVZlc3hkcER5NkZzSmh5VWxLQk9RWEhycFRTUVNiU1JvQ3BzZ0loQUx4eTREc3hYUWx4TE82Rk1yL3g5bjA0YlJjRC9GQnY1Szd5VVFRVm9SYmk=",
	"url": "",
	"dialog": {
		"callback_id": "callid",
		"title": "dialog title",
		"elements": [{
				"display_name": "Email",
				"name": "email",
				"type": "text"
			}
		]
	}
}

Thanks @WJ.CAI !

Looks like your URL is set to "". It cannot actually be blank as the Mattermost server needs a URL to send the submitted dialog payload to.

More information here: https://docs.mattermost.com/developer/interactive-dialogs.html#parameters

Let me know if you have further questions? Do you know which URL you want to send the dialog payload to?

Anyone can help me with this? I can’t open a dialog.
this is my JSON but i get a 400 error code in my response. I send this JSON to the mattermost api

   `{
      "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"
      }
    }`

We have the same problem, is this a bug?

Well, I solved it. My error was the way I made the HTTP request.

What I was doing delayed the request and the “trigger_id” expired. Remember that the “trigger_id” has a useful life of 3 seconds.

My recommendation is to try to use different ways to send the request because the JSON that I publish is correct.
Another observation from me was that it apparently did not send it properly as an “application / json”

1 Like

For people who read this article later. As NexusNine already said to try to use different ways to send the request i managed it by posting with the axios module.

Seeing same issue with the payload below but different error. Any Idea?

Payload:

{"trigger_id":"cjgxOGNpN2FhdGI1Ym1ocHdlbWt1MW9qYmM6NmJja2txeWJ0YmRldGd5aWZrMWlzNXR6MXk6MTYyNTM0Njg0ODk4NzpNRVVDSVFDMkF0RVpIRHFldTk5VmxhM2c5azNZMmYyRGpXanZqLzkwdVRMcC9scmN3d0lnS2lEUWlHU3RiS3R2QTREcUZHTVpGNjFGQTFiZlJWM2JnUTEvQzRGWGoxbz0=","url":"http://myapi.com/command","dialog":{"callback_id":"hello_world","title":"":"hello_world","icon_url":"https://mattermost.org/wp-content/uploads/2016/04/icon.png","introduction_text":"OOPS","notify_on_cancel":false,"state":"":"hello_world","submit_label":"Create","elements":[{"display_name":"Email","name":"email","type":"text","subtype":"email","placeholder":"password@example.com"}]}}

Error:

{"id"=>"api.context.invalid_body_param.app_error", "message"=>"Invalid or missing url in request body.", "detailed_error"=>"", "request_id"=>"oriap7f1opngb8duac6jf3mtjr", "status_code"=>400}