title: Android Volley - BasicNetwork.performRequest: Unexpected response code 400
body: <p><strong>Problem statement:</strong></p>
  
  <p>I am trying to access an REST API that will return a JSON object for various HTTP status codes (400, 403, 200 etc) using Volley.</p>
  
  <p>For any HTTP status other than 200, it seems the 'Unexpected response code 400' is a problem. Does anyone have a way to bypass this 'error'?</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>protected void getLogin() {   
      final String mURL = "https://somesite.com/api/login";
  
      EditText username = (EditText) findViewById(R.id.username);
      EditText password = (EditText) findViewById(R.id.password);
  
      // Post params to be sent to the server
      HashMap&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
      params.put("username", username.getText().toString());
      params.put("password", password.getText().toString());
  
      JsonObjectRequest req = new JsonObjectRequest(mURL, new JSONObject(
              params), new Response.Listener&lt;JSONObject&gt;() {
          @Override
          public void onResponse(JSONObject response) {
  
              try {
                  JSONObject obj = response
                          .getJSONObject("some_json_obj");
  
                  Log.w("myApp",
                          "status code..." + obj.getString("name"));
  
                  // VolleyLog.v("Response:%n %s", response.toString(4));
  
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          }
      }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
              Log.w("error in response", "Error: " + error.getMessage());
          }
      });
  
      // add the request object to the queue to be executed
      AppController.getInstance().addToRequestQueue(req);
  }
  </code></pre>