title: Posting interactive messages to slack using java
body: <p>I've been looking at this for a while now. I'm trying to post a message and some buttons to a slack channel using the url for chat.postMessage (<a href="https://slack.com/api/chat.postMessage" rel="nofollow noreferrer">https://slack.com/api/chat.postMessage</a>). That is the url stored in the messagePostURL variable. My PostingConstants.relevancePost variable is holding the exact JSON that is shown on the slack buttons tutorial for interactive messages found at <a href="https://api.slack.com/docs/message-buttons" rel="nofollow noreferrer">https://api.slack.com/docs/message-buttons</a> and I've added my channel name and token to the JSON code. The same JSON code works when sending it to a webhook, but not sending this directly to the chat.postMessage url. Why might this not work properly?</p>
  
  <pre><code>    String urlParameters  = PostingConstants.relevancePost;
      byte[] postData       = urlParameters.getBytes( StandardCharsets.UTF_8 );
      int    postDataLength = postData.length;
      //String request        = messagePostURL;
      URL    url            = new URL( messagePostURL );
      HttpURLConnection conn= (HttpURLConnection) url.openConnection();
      conn.setDoOutput( true );
      conn.setInstanceFollowRedirects( false );
      conn.setRequestMethod( "POST" );
      conn.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded");
      conn.setRequestProperty( "charset", "utf-8");
      conn.setRequestProperty( "Content-Length", Integer.toString( postDataLength ));
      conn.setUseCaches( false );
      try( DataOutputStream wr = new DataOutputStream( conn.getOutputStream())) {
          wr.write( postData );
      }
  </code></pre>
  
  <p>Printing conn.getResponseCode() gives 200 (this is good to my knowledge), and printing conn.getResponseMessage() gives OK (again should be good).</p>