没有参数名的Android HttpPost
过去我曾多次使用POST方法,但得到了这个奇怪的web服务。它在chrome扩展上运行良好,但我无法使用android获得此响应。如果缺少,请在代码中添加任何内容 这是我正在使用的代码没有参数名的Android HttpPost,android,http-post,Android,Http Post,过去我曾多次使用POST方法,但得到了这个奇怪的web服务。它在chrome扩展上运行良好,但我无法使用android获得此响应。如果缺少,请在代码中添加任何内容 这是我正在使用的代码 HttpParams param = new BasicHttpParams(); param.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
HttpParams param = new BasicHttpParams();
param.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
HttpClient httpclient = new DefaultHttpClient(param);
HttpPost httppost = new HttpPost(url);
Utils.showLogs(MyConstants.TAG, "ApplicationURL: " + url);
httppost.setHeader("Content-type", contentType);
HttpConnectionParams.setConnectionTimeout(param, MyConstants.WEBSERVICE_TIMEOUT);
HttpConnectionParams.setSoTimeout(param, MyConstants.WEBSERVICE_TIMEOUT);
String response = null;
try {
if (jsonObject == null) {
StringEntity entity = new StringEntity(json, HTTP.UTF_8);
httppost.setEntity(entity);
} else {
StringEntity stringEntity = new StringEntity(jsonObject.toString());
httppost.setEntity(stringEntity);
}
// Execute HTTP Post Request
HttpResponse httpResponse = httpclient.execute(httppost);
final int statusCode = httpResponse.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
return MyConstants.SERVER_NOT_RESPONDING;
}
HttpEntity httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);
谢谢您是否添加了AndroidManifest.xml
如果没有,请添加此选项即可 请详细解释问题,是否收到错误?Logcat?如果调试代码,请输入If statusCode!=HttpStatus.SC_确定吗?我收到响应,但其{消息:发生错误。}。它的服务器错误为500。您是访问服务器日志还是编写一些日志来检查此错误的主要详细信息?