Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8992517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:58:25+00:00 2026-06-15T22:58:25+00:00

Hi How do I properly make HTTP post request in android with this json

  • 0

Hi How do I properly make HTTP post request in android with this json based API.

curl -H "Content-type: application/json" -X POST \
-d '{    
  "service_key": "e93facc04764012d7bfb002500d5d1a6",
  "incident_key": "srv01/HTTP",
  "event_type": "trigger",
  "description": "FAILURE for production/HTTP on machine srv01.acme.com"
  }
}' \
"https://events.pagerduty.com/generic/2010-04-15/create_event.json"

I have this code but it is giving me status error of 400 – https://gist.github.com/26af7af09b509c0e8c2a#comments

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:58:26+00:00Added an answer on June 15, 2026 at 10:58 pm

    I got some code somewhere else here and it worked… 🙂

    public void requestAction(String service_key, String event_type, String incident_key, String description) 
    {
        HttpClient hc = new DefaultHttpClient();
        String message;
        HttpPost p = new HttpPost("https://events.pagerduty.com/generic/2010-04-15/create_event.json");
        JSONObject object = new JSONObject();
        try 
        {
            object.put("service_key", service_key); 
            object.put("event_type", event_type);
            object.put("incident_key", incident_key);
            object.put("description","PI RedPhone: "+description);
        } 
        catch (Exception ex) 
        { }
        try 
        {
            message = object.toString();
            p.setEntity(new StringEntity(message, "UTF8"));
            p.setHeader("Content-type", "application/json");
            HttpResponse resp = hc.execute(p);
            Log.d("Status line", "" + resp.getStatusLine().getStatusCode());
        } catch (Exception e) 
            {e.printStackTrace();}
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make http post request using the request module text = 'some
Assuming I sent the following request to my API: POST http://localhost:4940/api/cars HTTP/1.1 User-Agent: Fiddler
How can I make this print properly without using two printf calls? char* second
I am trying to make an Http POST to an Apache web server. I
I got the following basic script who make a basic POST request (I just
I try to make Cross Domain POST requests and get back JSON encoded responses,
I'm trying to make a POST request, and I can't seem to figure out
I'm trying to POST JSON data to a Web Api method but the JSON
I need to make an HTTP request to get back translated text. If I
I am trying to make a curl POST from java through java's Runtime. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.