我試圖執行GET請求到服務器,返回一個JSON文件。但是我在HTTP statusLine/422中發生錯誤。任何人都知道爲什麼。下面我展示我是如何做的錯誤在Android中的HTTP 422 GET
public void testConverteArquivoJsonEmObjetoJava() {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet get = new HttpGet(
"http://safe-sea-4024.ppooiheroku4554566adffasdfasdfalaqwerpcp.com/crimes/mobilelist");
get.setHeader("Accept", "application/json");
get.setHeader("Content-type", "application/json");
get.getParams()
.setParameter("token",
"0V1AYFK12SeCZHYgXbNMew==$tRqPNplipDwtbD0vxWv6GPJIT6Yk5abwca3IJ88888a6JhMs=");
HttpResponse httpResponse;
try {
httpResponse = httpClient.execute(get);
String jsonDeResposta = EntityUtils.toString(httpResponse
.getEntity());
System.out.println();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
HTTP狀態代碼表示無法處理的實體,這通常意味着你提供的數據不被服務器識別。您應該查閱API文檔以驗證呼叫需要哪些數據。另外,您是否包含在問題中的真實標記? – Perception
你可以粘貼異常追蹤嗎? –
是的,這個標記是有效的。但是服務器測試。 –