通过response_url webhook更新Slack临时消息时出现Invalid blocks错误
问题根因
你提交的请求体存在两处不符合Slack API规范的错误,直接触发了invalid_blocks报错:
- Block字段命名错误:Slack Block Kit 规范要求所有字段使用蛇形命名(下划线分隔),你在image块中使用的驼峰命名
imageUrl、altText属于非法字段,正确命名应为image_url、alt_text - 参数类型错误:
replace_original要求为布尔类型,你提交的是字符串类型的"true",需要改为布尔值true
修正后的请求体示例
{ "blocks": [ { "type": "image", "image_url": "https://example.com/image.jpeg", "alt_text": "alt-text", "title": { "type": "plain_text", "text": "some text" } }, { "type": "actions", "elements": [ { "type": "button", "text": { "type": "plain_text", "text": "Send", "emoji": false }, "value": "send", "style": "primary" }, { "type": "button", "text": { "type": "plain_text", "text": "Find new", "emoji": false }, "value": "some text" }, { "type": "button", "text": { "type": "plain_text", "text": "Cancel", "emoji": false }, "value": "cancel" } ] } ], "replace_original": true, "text": "some fallback text" }
修正后提交请求即可正常替换临时消息。
内容的提问来源于stack exchange,提问作者cardouken
相关产品推荐
相关产品推荐

