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);