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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:35:10+00:00 2026-05-30T21:35:10+00:00

i want to send data from android application to server (.NET) but it doesn’t

  • 0

i want to send data from android application to server (.NET) but it doesn’t work this is my code :

DefaultHttpClient hc=new DefaultHttpClient();  
ResponseHandler <String> res=new BasicResponseHandler();  
HttpPost postMethod=new HttpPost(myURl);  

postMethod.getParams().setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, Boolean.FALSE);
postMethod.getParams().setBooleanParameter( "http.protocol.expect-continue", false );
postMethod.setHeader( "Content-Type", "application/json" );

JSONObject json = new JSONObject();

json.put("TOKEN", channel_token).toString();
json.put("APPLICATIONDATASOURCEID", data_src_id).toString();
json.put("NEWSTITLE", Title_edittext.getText().toString().trim()).toString();
json.put("NEWSDETAILS", Details_edittext.getText().toString()).toString();      
json.put("ALERTSTARTSAT" , "12/03/2012/05/12");
json.put("ALERTENDSAT", "13/03/2012/06/12");
json.put("SENDPUSHNOTIFICATION", true);
json.put("EXPIREIMMEDIATELY", true);

Log.i("jason Object", json.toString());

StringEntity se = new StringEntity(json.toString());
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,"application/json"));
postMethod.setEntity(se);      

HttpResponse response = hc.execute(postMethod); 
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
String _response = convertStreamToString(is);
System.out.println("res  " + _response);

getting this as response from server “Expectaions Failed” . please tell me where is the problem.

  • 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-30T21:35:12+00:00Added an answer on May 30, 2026 at 9:35 pm

    set your Json request as below:

    final int TIMEOUT_MILLISEC = 10000;  // = 10 seconds
    
    HttpParams httpParams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MILLISEC);
    HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);
    HttpClient client = new DefaultHttpClient(httpParams);
    
    HttpPost request = new HttpPost(myURl);
    
    //set post request type
    request.setHeader(HTTP.CONTENT_TYPE, "application/json; charset=utf-8");
    
    //request result type
    request.setHeader("Accept", "application/json; charset=utf-8");
    
    JSONObject json = new JSONObject();
    .
    .
    .
    .
    .
    //and so on with rest of the code
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to send data from android application to local server (PHP) but it
I want to send data to server from client(Android), below is my format http://101.34.45.45/rawData?data={userId:guest1,timestamp:2010-07-01
I want to send complex data from my android to a remote server via
I want to send image and text data from Android phone to a Server.
I have an Android application from which I want to upload some data to
I want to send data from a c# application to a c++ application through
I am trying to send data from android to Django app. I want to
I want to be a able to securely send data from my Android App
How can I send data from my PHP server side App to Android Client
Hi all Im building a android application that requires data from a PHP server.

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.