I think your code is right. but try this to access the string from HttpEntity: String response_str = EntityUtils.toString (responseEntity, HTTP.UTF_8);
as I used in my method:
public String SetObjectSecurity(String username, String password, String clientName,String docRid,String ObjectRidsForCheckSum) throws JSONException, ClientProtocolException, IOException { String SetObjectSecurityURL = "url"; StringEntity str_request_entity = null; HttpResponse http_response = null; HttpGet getrequest = new HttpGet(SetObjectSecurityURL); postrequest.setHeader("Accept", "application/json"); postrequest.setHeader("Content-type", "application/json"); //set param here HttpClient httpClient = new DefaultHttpClient(); http_response = httpClient.execute(getrequest); //Log.e("Status code ",http_response); HttpEntity responseEntity = http_response.getEntity(); String response_str =EntityUtils.toString(responseEntity, HTTP.UTF_8); Log.e("output",response_str); int i = http_response.getStatusLine().getStatusCode(); Log.e("status","code "+i); if(i==this){ do this} else { this } return response_str; }
source share