HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(URL);
try {
StringEntity documentStringified = new StringEntity(Obj.toString());
httpPost.setEntity(documentStringified);
} catch (UnsupportedEncodingException e) {
Log.d("UnsupportedEncodingException", e.toString());
}
try {
HttpResponse response = httpClient.execute(httpPost);
Log.d("Response", response.toString());
} catch (IOException e) {
Log.d("IOException", e.toString());
}
我无法获得response
。如何在Logger or console.
response.toString()
或response.getEntity.toString()
中打印响应不起作用。获取JSON响应Android
我应该如何设置内容类型为"application/json"
。
and entity is nothing but response.getEntity()right? – Kevin
最后一个问题,我如何设置内容类型:'application/json'到我的http – Kevin
是的,实体是response.getEntity() –