Android volley show Unexpected response code 500


I use method POST with Volley library. All it work fine but not display toast “Successful”.

Below is code that I achieve update content with my server is successful.

String uri = "";
StringRequest request = new StringRequest(Request.Method.POST, uri,
                    new Response.Listener<String>() {
                        public void onResponse(String response) {

                            Toast.makeText(getApplicationContext(), "Successful" , Toast.LENGTH_SHORT).show();
                    new Response.ErrorListener() {
                        public void onErrorResponse(VolleyError error) {
                            Toast.makeText(getApplicationContext(), "Error: " + error, Toast.LENGTH_SHORT).show();
                protected Map<String, String> getParams() {
                    Map<String, String> params = new HashMap<String, String>();
                    params.put("participantId", editText2.getText().toString());
                    params.put("name", editText3.getText().toString());
                    return params;
            // Create Volley
            RequestQueue queue = Volley.newRequestQueue(this);

But in android studio show like this.

D/Volley: [1124] BasicNetwork.logSlowRequests: HTTP response for request=<[ ] 0x85adf657 NORMAL 1> [lifetime=5381], [size=704], [rc=500], [retryCount=1]
E/Volley: [1124] BasicNetwork.performRequest: Unexpected response code 500 for
D/EGL_emulation: eglMakeCurrent: 0xa3f85420: ver 2 0 (tinfo 0xa3f83350)
D/EGL_emulation: eglMakeCurrent: 0xa3f85420: ver 2 0 (tinfo 0xa3f83350)


It is an error from server side, nothing to do with volley

You can handle 500 error like this

public void onResponse(Response<YourModel> response) {
    if (response.code() == 200) {
       // Do awesome stuff
    } else if(response.code() == 500){
       Toast.makeText(this, "Error: internal server error", Toast.LENGTH_SHORT).show();

Answered By – SaravInfern

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published