如何修复StringRequest中的Android Volley错误?

问题描述 投票:0回答:1

我在http://202.158.68.155:7890/cobra/api/getDataByNopol中有API

如果我在邮递员中测试其工作,但在android凌空错误中为null

final RequestQueue requestQueue= Volley.newRequestQueue(getActivity());
    StringRequest stringRequest = new StringRequest(Request.Method.POST, "http://202.158.68.155:7890/cobra/api/getDataByNopol", new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            hideDialog();
            Log.e(TAG, "Response Detail -> "+response);
            requestQueue.stop();
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            VolleyLog.d("ERROR", error.getMessage());
            Toast.makeText(getActivity(),"ERROR "+error.getMessage(), Toast.LENGTH_LONG).show();
            requestQueue.stop();
        }
    }) {
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            Map<String, String> param = new HashMap<String, String>();

            param.put("nopol", "L 6967 TJ");
            param.put("username", "uat2");
            param.put("token", "02E184D3C82B6DA4750A214C4");
            return param;
        }
    };
    requestQueue.add(stringRequest);
    AppController.getInstance().addToRequestQueue(stringRequest, tag_json);
}

如何处理这种情况?

android android-volley
1个回答
0
投票
I have check above code please pass token as a header and please post the screenshot of postman
© www.soinside.com 2019 - 2024. All rights reserved.