<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content

Okta Workflows Invalid Blocks Error Occurs When Using the Slack Send Message to Channel Card

Workflows
Okta Classic Engine
Okta Identity Engine

Overview

When using the Slack connector Send Message to Channel card with the Message Type option set to Blocks and the Blocks input set to the JSON, an error is generated as the format from the Slack Block Kit Builder includes an outer blocks object wrapper. Removing the outer blocks key and object wrapper resolves the issue. 

Review the following for an example of the error:

message": "invalid_blocks",
  "code": 400,
  "description": "HTTP Request Error"

 

Error

Applies To

  • Okta Identity Engine (OIE)
  • Okta Classic Engine
  • Okta Workflows
  • Slack connector Send Message to Channel action card
  • Slack Blocks

Cause

Using the format from the Block Kit Builder provided by Slack to test API calls, such as the following, will result in the invalid blocks error when used with the Send Message to Channel card as the "blocks" key is added by the card already and not needed to be explicitly definied.

{
"blocks": [
  {
   "type": "actions",
   "block_id": "actions1",
   "elements": [
    {
     "type": "static_select",
     "placeholder": {
      "type": "plain_text",
      "text": "Which witch is the witchiest witch?"
     },
     "action_id": "select_2",
     "options": [
      {
       "text": {
        "type": "plain_text",
        "text": "Matilda"
       },
       "value": "matilda"
      },
      {
       "text": {
        "type": "plain_text",
        "text": "Glinda"
       },
       "value": "glinda"
      },
      {
       "text": {
        "type": "plain_text",
        "text": "Granny Weatherwax"
       },
       "value": "grannyWeatherwax"
      },
      {
       "text": {
        "type": "plain_text",
        "text": "Hermione"
       },
       "value": "hermione"
      }
     ]
    },
    {
     "type": "button",
     "text": {
      "type": "plain_text",
      "text": "Cancel"
     },
     "value": "cancel",
     "action_id": "button_1"
    }
   ]
  }
]
}

 

Solution

How is the invalid blocks error resolved?

Remove the outer blocks key, the associated object braces, and the array brackets from the JSON payload to resolve the invalid blocks error.

  1. Open the JSON payload generated by the Slack Block Kit Builder.
  2. Delete the "blocks": key.
  3. Delete the outer opening and closing curly braces { }.
  4. Delete the opening and closing square brackets [ ].

 

Compare the incorrect payload with the blocks key highlighted in red on the left and the correct payload on the right to understand the required formatting changes on an issue and a successful example.

incorrect payload vs. a successful example

Below is a working, altered version from example in the cause section above, format the JSON payload to match the provided example by removing the blocks key, outer object braces, and array brackets.

{
  "type": "actions",
  "block_id": "actions1",
  "elements": [
    {
      "type": "static_select",
      "placeholder": {
        "type": "plain_text",
        "text": "Which witch is the witchiest witch?"
      },
      "action_id": "select_2",
      "options": [
        {
          "text": {
            "type": "plain_text",
            "text": "Matilda"
          },
          "value": "matilda"
        },
        {
          "text": {
            "type": "plain_text",
            "text": "Glinda"
          },
          "value": "glinda"
        },
        {
          "text": {
            "type": "plain_text",
            "text": "Granny Weatherwax"
          },
          "value": "grannyWeatherwax"
        },
        {
          "text": {
            "type": "plain_text",
            "text": "Hermione"
          },
          "value": "hermione"
        }
      ]
    },
    {
      "type": "button",
      "text": {
        "type": "plain_text",
        "text": "Cancel"
      },
      "value": "cancel",
      "action_id": "button_1"
    }
  ]
}

Related References

Loading
Okta Workflows Invalid Blocks Error Occurs When Using the Slack Send Message to Channel Card | Okta Support