slack-api-docs icon indicating copy to clipboard operation
slack-api-docs copied to clipboard

chat.postMessage does not require text if attachments are present

Open rorhug opened this issue 11 years ago • 3 comments

Hi,

Even though https://slack.com/api/chat.postMessage is documented to require a text parameter it can actually succeed with no text and only attachments.

This is an issue because some libraries use the json in the docs to automatically code for api wrapping (with validations) and therefore they don't allow submission of attachments only.

dblock/slack-ruby-client#11

Example Request

https://slack.com/api/chat.postMessage?token=YOUR_TOKEN&channel=YOUR_CHANNEL_ID&attachments=%5B%7B%22title%22%3A%20%22hi%22%7D%5D

(&attachments is encoding the json string [{"title": "hi"}])

Once YOUR_TOKEN and YOUR_CHANNEL_ID have been replaced by a valid values, it will submit a message with attachment to the channel without any text parameter. Removing the attachment gives the error

{
    ok: false,
    error: "no_text"
}

which should really be something like no_text_or_attachment.

rorhug avatar Aug 20 '15 16:08 rorhug

Thanks for pointing this out! We have this on our list to look into. If you notice anything else in future, we'll be happy to help. You can let us know by emailing [email protected] where we'll be able to get you a faster reply, though we'll be keeping an eye on issues here, too. Thank you again!

awalla avatar Sep 04 '15 14:09 awalla

hitting this issue too in the ruby gem (doesn't allow to post without text)

mrbrdo avatar Sep 08 '15 15:09 mrbrdo

Hi,

I am having issues with chat.postMessage not working with attachments parameter. It stopped working around 4th-5th February. These are the return values. { error: "no_text", ok: false}

Attachments should work regardless of the text parameter. Is there any workaround or fix for this?

raoradica avatar Feb 20 '19 04:02 raoradica