Unexpected response code 500

2,145 views
Skip to first unread message

rahul.pi...@gmail.com

unread,
Jun 20, 2018, 7:30:19 AM6/20/18
to Volley Users
Hi everyone,

 I am trying a String request in volley but I am facing THE ERROR -  BasicNetwork.performRequest: Unexpected response code 500 for api(link).I have checked almost everywhere and didnt find any solution please help....


StringRequest stringRequest = new StringRequest(Request.Method.POST,url,new Response.Listener<String>() {
@Override
public void onResponse(String response) {
pg.dismiss();
try {
JSONObject obj = new JSONObject(response);
if (obj.getString("type").equalsIgnoreCase("success")) {
Toast.makeText(getApplicationContext(),"Successfully recorded the incident.",Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivity.this, obj.getString("msg"), Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}

}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
pg.dismiss();
String TAG = "myLogs";
Log.e(TAG, "onErrorResponse: " + error.toString());
Toast.makeText(MainActivity.this, error.toString(), Toast.LENGTH_SHORT).show();
}
}) {
@Override
protected Map<String,String> getParams() throws AuthFailureError {
Map<String,String> params = new HashMap<String, String>();
params.put("report_type",s);
params.put("intervene_exist",sp2);
params.put("shift",sp1);

return params;
}
};

RequestQueue requestQueue = Volley.newRequestQueue(MainActivity.this);
requestQueue.add(stringRequest);

Jeff Davidson

unread,
Jun 21, 2018, 2:14:00 PM6/21/18
to rahul.pi...@gmail.com, Volley Users
Given that this is a server-generated error, I would suggest you check the server logs for why it is rejecting your request. You can also check the response body in onErrorResponse using error.networkResponse.data - often this will contain an error message, although it's up to the server as to whether that error will include enough detail to diagnose the problem.

--
You received this message because you are subscribed to the Google Groups "Volley Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to volley-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages