我正在尝试访问 RESTfull 网络服务器。链接是Railyatri。当我通过我的 android 应用程序访问它时,我得到空的响应。当我通过我的 PC 浏览器做同样的事情时,我得到了所需的数据 (JSON)。
这就是我在android中发出http请求的方式
HttpClient stageClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
try
{
HttpResponse response = stageClient.execute(httpGet);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if(statusCode == 200)
{
HttpEntity entity = response.getEntity();
InputStream inputStream = entity.getContent();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = bufferedReader.readLine()) != null)
{
data.append(line);
isSuccess = true;
}
}
else
{
isSuccess = false;
}
}
catch (ClientProtocolException clientProtocolException) {
}
catch (IOException ioException) {
}
我得到的状态代码为 200。有人能指出我在做什么错误。