title: BasicNetwork.performRequest: Unexpected response code 400 for https://api.infermedica.com/v2/diagnosis - Android Java
body: <p>I'm testing the inter media API and I am trying it using this code below. I used volley for this:</p>
  
  <pre><code>    String url = "https://api.infermedica.com/v2/diagnosis";
      JSONArray evidence = new JSONArray();
      JSONObject evidence1 = new JSONObject();
      try {
          evidence1.put("id", "s_1193");
          evidence1.put("choice_id", "present");
      } catch (JSONException e) {
          e.printStackTrace();
      }
  
      try {
          evidence.put(0,evidence1);
      } catch (JSONException e) {
          e.printStackTrace();
      }
  
      JSONObject postparams  = new JSONObject();
      try {
          postparams.put("sex", "male");
          postparams.put("age", 30);
          postparams.put("evidence", evidence);
      } catch (JSONException e) {
          e.printStackTrace();
      }
  
      Log.e("DATA:", postparams.toString());
      JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.POST,
              url, postparams,
              new Response.Listener() {
                  @Override
                  public void onResponse(Object response) {
                      Log.e("DATA: ", response.toString());
                  }
              },
              new Response.ErrorListener() {
                  @Override
                  public void onErrorResponse(VolleyError error) {
                      // As of f605da3 the following should work
                      NetworkResponse response = error.networkResponse;
                      if (error instanceof ServerError &amp;&amp; response != null) {
                          try {
                              String res = new String(response.data,
                                      HttpHeaderParser.parseCharset(response.headers, "utf-8"));
                              // Now you can use any deserializer to make sense of data
                              JSONObject obj = new JSONObject(res);
                              Log.e("DATA:" , obj.toString());
                          } catch (UnsupportedEncodingException e1) {
                              // Couldn't properly decode data to string
                              e1.printStackTrace();
                          } catch (JSONException e2) {
                              // returned data is not JSONObject?
                              e2.printStackTrace();
                          }
                      }
                  }
              }
  
      ) {
          @Override
          public Map&lt;String, String&gt; getHeaders() throws AuthFailureError {
              HashMap&lt;String, String&gt; headers = new HashMap&lt;String, String&gt;();
              headers.put("app-id", "MY-APP-ID");
              headers.put("app-key", "MY-APP-KEY");
              headers.put("authorization", "Basic Og==");
              headers.put("Content-type", "application/json");
              return headers;
          }
      };
  
  
      Log.e("DATA: " , "calling volley");
      RequestQueue requestQueue  = Volley.newRequestQueue(this);
      requestQueue.add(jsonObjReq);
  </code></pre>
  
  <p>After running it and checking the logs here is the result:</p>
  
  <pre><code> E/DATA:: {"sex":"male","age":30,"evidence":
   [{"id":"s_1193","choice_id":"present"}]}
  
   E/DATA:: calling volley
  
   E/Volley: [236] BasicNetwork.performRequest: Unexpected response code 400 
   for https://api.infermedica.com/v2/diagnosis
  
   E/DATA:: {"message":"bad request"}
  </code></pre>
  
  <p>I tried the logged json in Postman and it was accepted:</p>
  
  <p><strong>Here is the screenshot of my postman result</strong></p>
  
  <p><a href="https://i.stack.imgur.com/6DvhO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6DvhO.png" alt="postman result"></a></p>
  
  <p>I've been looking for answers around here, I already added the content-type, and I made sure that my keys are correct. Am I using the volley correctly. Your help will be much appreciated.</p>