Skip to content

Instantly share code, notes, and snippets.

@vedant1811
Created May 19, 2016 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vedant1811/68018643a380fe9e9e58d822904c611f to your computer and use it in GitHub Desktop.
Save vedant1811/68018643a380fe9e9e58d822904c611f to your computer and use it in GitHub Desktop.
require 'net/http'
uri = URI.parse 'https://hooks.slack.com/services/...'
# Create the HTTP objects
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)
request.body = '{"text": "This is a line of text in a channel.\nAnd this is another line of text."}'
# Send the request
response = http.request(request)
puts "slack response #{response.body}"
slack response <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: xJyUEpQt9DLs-G_5tmey_0t4sMrCY-GnNO8QL9DKsMP6giMDdmvw7g==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment