Skip to content

Instantly share code, notes, and snippets.

@baskarp
Created October 29, 2012 09:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save baskarp/3972633 to your computer and use it in GitHub Desktop.
Save baskarp/3972633 to your computer and use it in GitHub Desktop.
Invoke PagerDuty using cURL from Windows
@echo off
:: Download cURL with SSL support from here: http://www.paehl.com/open_source/?CURL_7.28.0:
:: Extract curl.exe in the same directory as this bat file
:: Usage: pagerduty.bat service_key event_type description incident_key
:: event_types = (trigger | acknowledge | resolve)
::
set service_key=%1
set service_key=%service_key:"=\"%
set event_type=%2
set event_type=%event_type:"=\"%
set description=%3
set description=%description:"=\"%
set incident_key=%4
set incident_key=%incident_key:"=\"%
curl -H "Content-type: application/json" -k -X POST -d "{\"service_key\": %service_key%, \"event_type\": %event_type%, \"incident_key\": %incident_key%, \"description\": %description% }" "https://events.pagerduty.com/generic/2010-04-15/create_event.json"
@nickjwebb
Copy link

Thanks for this, just implemented it today!

Note for the next folks, you do have to quote and escape each element in the JSON, here is what worked for me for the last line of the script:
curl -H "Content-type: application/json" -k -X POST -d "{\"service_key\": \"%service_key%\", \"event_type\": \"%event_type%\", \"incident_key\": \"%incident_key%\", \"description\": \"%description%\" }" "https://events.pagerduty.com/generic/2010-04-15/create_event.json"

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