Created
August 26, 2012 03:29
-
-
Save rtekie/3473580 to your computer and use it in GitHub Desktop.
Ruby example of using API to notify CronSentry upon a job completion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ruby example of using API to notify CronSentry upon a job completion | |
# For API documentation please go to http://www.cronsentry.com/help#api | |
require 'open-uri' | |
require 'rest_client' | |
# set POST variables | |
url = 'http://api.cronsentry.com/api/v1/notifications' | |
api_key = 'YOUR_API_KEY' | |
job_name = URI::encode('Your job name') | |
status = 1 | |
message = URI::encode('Please change me') | |
# do POST | |
response = RestClient.post( url, | |
{ | |
:api_key => api_key, | |
:job_name => job_name, | |
:status => status, | |
:message => message | |
}) | |
# check response | |
puts "Response code: #{response.code}" | |
puts "Response body: #{response.body}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment