我想将带有两个参数的 POST 请求从 JsonObject 发送到 python API,它以 True 或 False 响应,但它根本不起作用......
我的代码:
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.30.0.47:8080/getsession");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("Name", db.getString("name")));
nameValuePairs.add(new BasicNameValuePair("Passwort", db.getString("passwort")));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse res = httpclient.execute(httppost);
Log.v("Response", res.toString());
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}