Skip to content

Instantly share code, notes, and snippets.

@1c7
Created January 23, 2019 10:42
Show Gist options
  • Save 1c7/5b7db41613da0b51a596ebbbee4e62d3 to your computer and use it in GitHub Desktop.
Save 1c7/5b7db41613da0b51a596ebbbee4e62d3 to your computer and use it in GitHub Desktop.
Slack webhook example curl->Ruby
class SlackIdVerifyJobJob < ApplicationJob
queue_as :default
def perform()
# curl -X POST -H 'Content-type: application/json' --data '{"text":"Hello, World!"}' https://hooks.slack.com/services/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
# Equivalent ruby code:
url = "https://hooks.slack.com/services/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"
options = {
body: {"text": "Hello, World!"}.to_json,
headers: {"Content-Type" => "application/json"},
}
response = HTTParty.post(url, options)
puts response
end
end
@1c7
Copy link
Author

1c7 commented Jan 23, 2019

image

@1c7
Copy link
Author

1c7 commented Jan 23, 2019

Slack use curl for example

this gist turn curl example into Ruby code.

you can copy&paste into your project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment