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.
set your Json request as below: