I've been looking all over the internet for this, and I just haven't found an answer that works. I'm trying to make a bukkit plugin that sends data to an ingoing Slack webhook when a command is run. I've gotten to noticing the command running, but I have no idea how to send the JSON. (For those of you unfamiliar with Slack, the command inside a terminal window is curl -X POST --data-urlencode 'payload={"channel":"#slack-channel-id","username":"bot's username","text":"Self explanatory","icon_emoji":"The bot's icon"}' https://slack.com/custom/webhook/token/here I've been looking all over and googling for a good hour trying to find a way in Java to send this. But no matter what I try it doesn't work. Any help is appreciated, thanks
//You can use the following code it works! slackWebhook is the https endpoint for the channel that you can get from custom_integration link
    String payload = "payload={\"channel\": \"#channel_name\", \"text\": \"This is posted "
            + "to #ewe_gps_abacus_notif and comes from a bot named change-alert.\"}";
    StringEntity entity = new StringEntity(payload,
            ContentType.APPLICATION_FORM_URLENCODED);
    HttpClient httpClient = HttpClientBuilder.create().build();
    HttpPost request = new HttpPost(slackWebhook);
    request.setEntity(entity);
    HttpResponse response = null;
    try {
        response = httpClient.execute(request);
    } catch (IOException e) {
        e.printStackTrace();
    }
    System.out.println(response.getStatusLine().getStatusCode());
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With