Volleyball 500 feedback response code

I always get below error response when using volley

06-24 15:06:59.244: E/Volley(12869): [2311] BasicNetwork.performRequest: Unexpected response code 500 for http://My_API

      

my code for calling Volley

String sSignupUrl = STController.getInstance()
                .getResourceManager(LoginActivity.this)
                .getServerPropertyValue(URLConstants.API_LOGIN);
JSONObject params = new JSONObject();
        try {
            params.put("username", "usernam");
            params.put("passwd", "password");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        JsonObjectRequest jsonObjReq = new JsonObjectRequest(Method.POST,
                sSignupUrl, params, new Response.Listener<JSONObject>() {

                    @Override
                    public void onResponse(JSONObject response) {
                        LogUtil.d("TAG" + response.toString());
                    }
                }, new Response.ErrorListener() {

                    @Override
                    public void onErrorResponse(VolleyError error) {
                        VolleyLog.d("TAG", "Error: " + error.getMessage());
                    }
                }) {

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                HashMap<String, String> headers = new HashMap<String, String>();
                headers.put("Content-Type", "application/json; charset=utf-8");
                return headers;
            }

        };

        // Adding request to request queue
        AppController.getInstance().addToRequestQueue(jsonObjReq);

      

I can successfully get the answer when using the URLConnection dispatcher, unable to find the error, I have a google search but dont get the correct solution, all answers are most welcome Thanks in advance

+3


source to share


1 answer


I had the same situation. What I did wrong was what I included getHeaders()

in the wrong one JsonObjectRequest(i.e. with a wrong url)

. But I used my own title in my situation. Check your URL. This may not be true. It may not accept this header.



+2


source







All Articles