RESTfull Web サーバーにアクセスしようとしています。リンクは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 になっています。だれか、私がやっている間違いを指摘してもらえますか。