我必须从android应用程序发送json数组到服务器。我能够通过httpget发送数据但我想通过httppost发送它我看到了示例但我的数据没有发布。
我得到了响应代码200,即使我在url中传递了错误的参数,这背后的原因是什么。
这是我的代码:
DefaultHttpClient UserIDclient = MySSLSocketFactory.getNewHttpClient();
HttpPost httppost = new HttpPost("my url");
List<BasicNameValuePair> nvps = new ArrayList<BasicNameValuePair>();
nvps.add(new BasicNameValuePair("api","apiname"));
nvps.add(new BasicNameValuePair("user_id","179"));
nvps.add(new BasicNameValuePair("child_id","94"));
nvps.add(new BasicNameValuePair("json",json array));
UrlEncodedFormEntity p_entity = new UrlEncodedFormEntity(nvps,HTTP.UTF_8);
httppost.setEntity(p_entity);
HttpResponse response = UserIDclient.execute(httppost);