Android:HttpGet与Params失败

时间:2016-09-14 14:14:56

标签: android apache apache-httpclient-4.x http-get

我正在使用Apache HttpClient,DefaultHttpClient,HttpResponse来使用JsonObject作为请求参数来生成HttpGet请求。我收到JsonObject格式的响应.Content-Type是application / json

问题是,一旦登录请求失败,则在下次更正详细信息时提供不正确的登录详细信息时,您始终无法获得成功响应。 如果第一次登录成功,则不会发生此情况。

我怀疑params没有正确通过,虽然我已经检查了相同。是否有可能缓存上一个请求并且新的参数不会通过。

JSONObject inputBodyObject = new JSONObject();
inputBodyObject.put("email", emailId);
inputBodyObject.put("password", password);
String strURL = this.getString(R.string.base_url) + this.getString(R.string.action_login) + Uri.encode(inputBodyObject.toString());

HttpGet httpGet = new HttpGet(strURL);
httpGet.setHeader("Content-type", "application/json"));
HttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();

0 个答案:

没有答案
相关问题