-
-
Save romelemperado/3fb2d2249152eb3359d4 to your computer and use it in GitHub Desktop.
httprequest.java
This file contains 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
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