I am getting this error while making a network request using volley library,I have followed these links Android Volley - BasicNetwork.performRequest: Unexpected response code 400 and Unexpected response code 404 volley but none of them working in my case . Here is my request code
StringRequest stringRequest = new StringRequest(Request.Method.POST,AppConstants.LOG_IN_API , new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d("TAG", "Login Response: " + response.toString());
try {
JSONObject jsonObject = new JSONObject(response);
Log.v("USerid",""+jsonObject.getInt("userid"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
System.out.println("volley Error ................."+volleyError);
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Log.v("getparams","Is called");
Map<String, String> params = new HashMap<String, String>();
params.put(AppConstants.USER_ID, "[email protected]");
params.put(AppConstants.PASSWORD, "123456");
return params;
}
@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;
}
};
Log.v("Request",""+stringRequest);
AppController.getInstance().addToRequestQueue(stringRequest);
}
Is there anyone who can tell me where I am doing wrong in my code? Any help is appreciable.