slackhq / slack-api-docs

API Docs for Slack.com
https://api.slack.com/
426 stars 85 forks source link

chat.postMessage does not require text if attachments are present #41

Closed rorhug closed 9 years ago

rorhug commented 9 years ago

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.

awalla commented 9 years ago

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 feedback@slack.com 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!

mrbrdo commented 9 years ago

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

raoradica commented 5 years ago

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?