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 4096440
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:02:47+00:00 2026-05-20T20:02:47+00:00

I am sending post request from android to the url using httpclient like this

  • 0

I am sending post request from android to the url using httpclient like this one below –

String url = “http://www.myurl.com/test.php?format=json”;

Now I am getting response back in form of plist instead of json, which is default type of response from php file if no format query string is described in url.

Can we specify query string in url while posting? It looks like php file is not getting format query string.

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("method", "add"));
nameValuePairs.add(new BasicNameValuePair("device_id", "123"));
nameValuePairs.add(new BasicNameValuePair("device_token", "3221"));
nameValuePairs.add(new BasicNameValuePair("session_id", "1212"));
nameValuePairs.add(new BasicNameValuePair("event_id","12345" ));

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);                      httppost.addHeader("Content-Type","application/x-www-form-urlencoded");
httppost.addHeader("Accept","application/json");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));
HttpResponse response = httpclient.execute(httppost);

/* Checking response */
if (response != null) {
     InputStream in = response.getEntity().getContent();
     String a = convertStreamToString(in);
    Log.i("Read from Server "+response.getStatusLine().getStatusCode(), a);
}else{
    Log.i("response is ", "null");

}

Thanks

  • 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-20T20:02:48+00:00Added an answer on May 20, 2026 at 8:02 pm

    It’s impossible to know without seeing your server code, but your server may not like that you’re combining HTTP POST parameters in your request body with GET parameters in the URL. Try putting

    nameValuePairs.add(new BasicNameValuePair("format","json" ));
    

    into the section where you’re building up the request parameters instead and see what happens.

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

Sidebar

Related Questions

I got some sample code from the net here: http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class That works fine. It
I am sending a POST request using HTTPWebRequest from the client to the Cassini
I'm sending an HTTP POST request to a URL. It sends back a piece
I'm sending an HTTP POST request from my C++ app to a PHP script
I am sending a POST request to a Server from my Android Application. The
I am an sending a HTTP POST request from a Google Web Toolkit app
I'm sending an HTTP PUT request from a WinForms application and I'd like to
I have a problem sending POST request with VB6. The code below works properly
I have a problem with sending POST http request. It stops on (HttpWebResponse)request.GetResponse() and
I'm sending a POST to a URL, with content type as application/x-www-form-urlencoded and in

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.