Skip to content

Instantly share code, notes, and snippets.

@romelemperado
Created December 10, 2012 15:54
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 romelemperado/3fb2d2249152eb3359d4 to your computer and use it in GitHub Desktop.
Save romelemperado/3fb2d2249152eb3359d4 to your computer and use it in GitHub Desktop.
httprequest.java
public void request()
{
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://events.pagerduty.com/generic/2010-04-15/create_event.json");
try
{
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("service_key", "c2181140eexxxxxxxxxx009e57"));
nameValuePairs.add(new BasicNameValuePair("event_type", "trigger"));
nameValuePairs.add(new BasicNameValuePair("description", "test"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
stopSelf();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment