Win a copy of High Performance Python for Data Analytics this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

How can I send a slack channel message using Java?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I have a text area to type a message into, and I store that text in String message; How can I send that to a specified slack channel? I have created a slack app and generated an incoming webhook for it but am not sure how to use this.
 
Saloon Keeper
Posts: 6802
162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is an HTTP API: https://api.slack.com/messaging/sending
 
Stephen Merriam
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:There is an HTTP API: https://api.slack.com/messaging/sending



I have now gotten a slack message sender set up, but when I try to send I get this error:
 
Tim Moores
Saloon Keeper
Posts: 6802
162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The API seems to have dependencies - be sure to add all of them to your classpath, whatever they may be. In this case, slf4j.
 
Stephen Merriam
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:The API seems to have dependencies - be sure to add all of them to your classpath, whatever they may be. In this case, slf4j.



Every time I added the dependency, a new error for a new dependency would pop up. I added 6 new jars before I got an error saying that one of them had an improper method definition in it. Do you know if there is a better way to send a slack message than with
 
Saloon Keeper
Posts: 23055
157
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Stephen!

This is the reason that application builders like Maven and Gradle were created. It's very common for Java apps to depend on a multitude of libraries that those tools excel in fetching them - and their dependencies and integrating them into tbe module being built.

Your first dependeny was slf4j - the Simple Logging Facade for Java, and it's actually a bit of glue that fixes the problem when you are pulling in different libraries that use different loggers (such as juli and lof4j) and makes them all work together seamlessly. However, it depends, in turn in many cases on pulling in a logger and/or slf4j bridge. And so it goes.

Ideally the Slack API docs will tell you what it wants and perhaps even have build examples, but some vendors are better at that than others, alas.
 
Marshal
Posts: 26308
80
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:This is the reason that application builders like Maven and Gradle were created.



Indeed. The tutorial I found when I googled the topic title started out by recommending Maven and explaining how to use it.
 
Barry's not gonna like this. Barry's not gonna like this one bit. What is Barry's deal with tiny ads?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic