How do I post a snippet to slack channel

Jerrod Horton picture Jerrod Horton · Oct 25, 2016 · Viewed 13.3k times · Source

I am trying to post log info to slack and some of these logs can get pretty big. Is there a way to send it as a snippet so that slack doesn't chunk the text into multiple messages?

Answer

Erik Kalkoken picture Erik Kalkoken · Nov 4, 2016

You can post a snippet to a Slack channel using the API method files.upload.

In order for this to work you need to:

  • Use the content (not the file) parameter to upload the content of your file.
  • Provide the name of the channel in the channels parameter where the snippet should be posted.
  • The filetype is optional. Slack will determine the type of your file based on the filename or "magic bytes" of the file. e.g. using text as filetype will work.