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

  • Home
  • SEARCH
  • 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 6023881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:04:19+00:00 2026-05-23T04:04:19+00:00

I am sending a JSON object to a HTTP Server by using the following

  • 0

I am sending a JSON object to a HTTP Server by using the following code.

The main thing is that I have to send Boolean values also.

public void getServerData() throws JSONException, ClientProtocolException, IOException {

    ArrayList<String> stringData = new ArrayList<String>();
    DefaultHttpClient httpClient = new DefaultHttpClient();
    ResponseHandler <String> resonseHandler = new BasicResponseHandler();
    HttpPost postMethod = new HttpPost("http://consulting.for-the.biz/TicketMasterDev/TicketService.svc/SaveCustomer");

    JSONObject json = new JSONObject();
    json.put("AlertEmail",true);
    json.put("APIKey","abc123456789");
    json.put("Id",0);
    json.put("Phone",number.getText().toString());
    json.put("Name",name.getText().toString());
    json.put("Email",email.getText().toString());
    json.put("AlertPhone",false);      
    postMethod.setEntity(new ByteArrayEntity(json.toString().getBytes("UTF8")));
    String response = httpClient.execute(postMethod,resonseHandler);
    Log.e("response :", response);
    }

but its showing the exception in the line

String response = httpClient.execute(postMethod,resonseHandler);

as

org.apache.http.client.HttpResponseException: Bad Request

can any one help me.

  • 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-05-23T04:04:20+00:00Added an answer on May 23, 2026 at 4:04 am

    The Bad Request is the server saying that it doesn’t like something in your POST.

    The only obvious problem that I can see is that you’re not telling the server that you’re sending it JSON, so you may need to set a Content-Type header to indicate that the body is application/json:

    postMethod.setHeader( "Content-Type", "application/json" );
    

    If that doesn’t work, you may need to look at the server logs to see why it doesn’t like your POST.

    If you don’t have direct access to the server logs, then you need to liaise with the owner of the server to try and debug things. It could be that the format of your JSON is slightly wrong, there’s a required field missing, or some other such problem.

    If you can’t get access use to the owner of the server, the you could try using a packet sniffer, such as WireShark, to capture packets both from your app, and from a successful POST and compare the two to try and work out what is different. This can be a little bit like finding a needle in a haystack though, particularly for large bodies.

    If you can’t get an example of a successful POST, then you’re pretty well stuffed, as you have no point of reference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that is sending a JSON object (formatted with Prototype) to
Am am successfully parsing and sending JSON values from my client for my server
sending mail along with embedded image using asp.net I have already used following but
I'm sending a JSON object to PHP using jQuery via $.ajax({ url: myURL, type:
I have been happy serializing with javascript objects into JSON using JSON.stringify And sending
I have the following json data in a Javascript variable result : [ Object
I have an object model called MyObject that I'm serializing to a json string
I have an MVC project that provides (GET) & consumes (PUT) a Json object.
I am trying to receive a json object back from php after sending data
I am sending messages in JSON format to an ActiveMQ server. I am trying

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.