BlockchainProgrammer
BlockchainProgrammer

Reputation: 2069

SlackBot OpenModal Error: "Missing Charset"

I want to make an api Call via Zapier to open a Modal in Slack.

But I always get the error:

ok: false
error:  invalid_json
warning:    missing_charset
response_metadata:
warnings:
1:  missing_charset

This is my Request Body:

{
"token":"XXXXXXXXX",
"trigger_id":"XXXXXXXXXX",
"dialog": {
  "callback_id": "projekt-verantwortliche",
  "title": "Projektverantwortliche auswählen",
  "submit_label": "Request",
  "state": "Limo",
  "elements": [
    {
      "type": "users_select",
      "action_id": "projekt-projektleiter",
      "placeholder": {
         "type":"plain_text",
         "text":"Projektleiter auswählen"
        },
    },
     {
      "type": "users_select",
      "action_id":"projekt-berater",
      "placeholder": {
         "type":"plain_text",
         "text":"Berater auswählen"
        }
    }
  ]
}
}

What am I doing wrong?

Here a Screenshot of the whole call: enter image description here

Upvotes: 10

Views: 28452

Answers (1)

flaxel
flaxel

Reputation: 4587

The solution can be found in this documentation:

The JSON you've included in your POST body cannot be parsed. This might be because it's actually not JSON, or perhaps you did not correctly set your HTTP Content-type header. Make sure your JSON attribute keys are strings wrapped with double-quote (") characters.

You only need to remove one comma, then it should work:

{
   "token":"XXXXXXXXX",
   "trigger_id":"XXXXXXXXXX",
   "dialog":{
      "callback_id":"projekt-verantwortliche",
      "title":"Projektverantwortliche auswählen",
      "submit_label":"Request",
      "state":"Limo",
      "elements":[
         {
            "type":"users_select",
            "action_id":"projekt-projektleiter",
            "placeholder":{
               "type":"plain_text",
               "text":"Projektleiter auswählen"
            }
         },
         {
            "type":"users_select",
            "action_id":"projekt-berater",
            "placeholder":{
               "type":"plain_text",
               "text":"Berater auswählen"
            }
         }
      ]
   }
}

You can remove the warning missing_charset if you set the charset for the content-type header. For example:

Content-type: application/json; charset=utf-8

Upvotes: 22

Related Questions