I'm trying to send a message using Slack incoming webhooks. I have the following code. It runs, but when I check my slack, there is no message. Can anyone see what I may have done wrong.
public class SlackTest {
static String web_hook_url = "https://hooks.slack.com/services/***********/******************";
public static void main(String[] args) {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(web_hook_url);
try {
String json = "{\"name\": John}";
System.out.println(json);
StringEntity entity = new StringEntity(json);
httpPost.setEntity(entity);
httpPost.setHeader("Accept", "application/json");
httpPost.setHeader("Content-type", "application/json");
client.execute(httpPost);
client.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}