Slack Api "attachments" Not Showing
Attachments aren't working in the following code and neither is the response_type showing as it should be. I've also tried using Python's Slack Client, but the exact same thing is
Solution 1:
The response_type
field can only be set when producing a message in response to a slash command or message button action invocation. It can't be set directly with chat.postMessage
, as there's no context on the target user for whom to display that ephemeral message.
Another quirk about chat.postMessage
is that it doesn't currently accept JSON like incoming webhooks does. Instead, you need to send POST parameters of the application/x-www-form-urlencoded
variety. Even quirkier, that attachments
field actually doesn't get sent as a string of JSON, but URL-encoded into a parameter.
One more tip, with chat.postMessage
and other write methods, you should use an HTTP POST instead of a GET.
Solution 2:
attachments='[{"title": "Try these - ","text": " Text ", "mrkdwn_in":["text"]}]'
Add the title to the attachment. It worked in my case.
Post a Comment for "Slack Api "attachments" Not Showing"