我想通過POST提交一個HTTPS請求,但它不起作用。該請求帶我到onErrorResponse,但沒有顯示錯誤是什麼。我用郵差測試,它工作正常。 我離開了我的部分代碼。使用Android Volley的HTTPS請求
Map<String, String> params = new HashMap<String, String>();
params.put(PARAM_HASH_TOKEN, HASH_TOKEN);
params.put(PARAM_USUARIO, id);
params.put(PARAM_PASSWORD, password);
JSONObject jsonBody = new JSONObject(params);
Log.e("POST",jsonBody.toString());
JsonObjectRequest mJsonObjectRequest = new JsonObjectRequest(Request.Method.POST, URL_API, jsonBody, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
if (response != null) {
F_PARSEAR_JSON_RESPUESTA(response);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
String msg = (error.getMessage() == null) ? "Ha ocurrido un error, intentelo de nuevo." : error.getMessage();
Log.e("ERROR",URL_API);
Log.e("ERROR",msg);
_loginButton.setEnabled(true);
}
});
ApplicationLoader.getInstance().addToRequestQueue(mJsonObjectRequest);
你是什麼意思,不顯示錯誤?你在調試器中運行並確認它是空的嗎? –
@sam_c沒錯,我正在使用調試器,並沒有顯示錯誤。 – user3281600