我有GET
的简单链接从服务器检索数据,这些数据在Windows服务器上实现,我的android应用程序必须从中获取数据,响应为json
格式,例如当我使用此FireFox
地址栏上的链接:
http://MY_SITE/android/main.aspx?page=1&cat=0
我得到JsonArray
回复:
[{"ID":27,"Number":"03331514800","Price":1500000,"Date":"","Status":0,"Cat":"$1$4$8$8$9$23$","SalesName":null,"TransID":null,"SalesDate":null,"SalesTime":null,"SalesSuccess":false}]
正确但我在使用Unexpected response code 500
库
Volley
我的代码:
private void getLatestSimCardNumbers() {
fetch_server_url = Application.getHostAddress() + "http://MY_SITE/android/main.aspx";
HashMap<String, String> jsonBody = new HashMap<>();
jsonBody.put("page", "1");
jsonBody.put("cat", "0");
HttpsTrustManager.allowAllSSL();
JsonArrayRequest req = new JsonArrayRequest(fetch_server_url, new JSONObject(jsonBody),
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.e("RESPONSE", response.toString());
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("ERR ", "");
}
});
int socketTimeout = 30000;
RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
req.setRetryPolicy(policy);
Application.getInstance().addToRequestQueue(req);
}