title: Android Volley Library StringRequest error
body: <p>I want to send a request to my REST API using the volley library in android.</p>
  
  <pre><code>             try {
          RequestQueue requestQueue = Volley.newRequestQueue(this);
          JSONObject jsonBody = new JSONObject();
          jsonBody.put("first_name", firstName);
          jsonBody.put("last_name", lastName);
          jsonBody.put("email", email);
          jsonBody.put("password", password);
  
          final String requestBody = jsonBody.toString();
  
          StringRequest stringRequest = new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener&lt;String&gt;() {
              @Override
              public void onResponse(String response) {
                  Log.d(TAG, "Register Response: " + response);
                  hideDialog();
  
                  try {
                      JSONObject jObj = new JSONObject(response);
                      String message = jObj.getString("msg");
  
                      if (message.equals("User created successfully")){
  
                          JSONObject user = jObj.getJSONObject("user");
                          String first_name = user.getString("first_name");
                          String last_name = user.getString("last_name");
                          String email = user.getString("email");
                          int id = user.getInt("id");
  
                          db.addUser(first_name, last_name, email, id);
                          Toast.makeText(getApplicationContext(), "User successfully registered. Try login now!", Toast.LENGTH_LONG).show();
  
                          login(email, password);
                          /*Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
                          startActivity(intent);
                          finish(); */
                      } else {
                          Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
                      }
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              }
          }, new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                  Log.e("VOLLEY", error.toString());
                  hideDialog();
                  //TODO give the error to the user and close the dialog box
              }
          }) {
              @Override
              public String getBodyContentType() {
                  return "application/json";
              }
  
              @Override
              public byte[] getBody() throws AuthFailureError {
                  return requestBody.getBytes();
  
              }
          };
  
          requestQueue.add(stringRequest);
      } catch (JSONException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>I create the jsonBody correctly, and want to send the request to AppConfig.URL_login, which is localhost:8000/api/v1/user/signin </p>
  
  <p>The error message: </p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
                Process: com.example.android.besecure, PID: 3915
                java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference
                    at com.android.volley.Request.&lt;init&gt;(Request.java:136)
                    at com.android.volley.toolbox.StringRequest.&lt;init&gt;(StringRequest.java:43)
                    at com.example.android.besecure.LoginActivity$5.&lt;init&gt;(LoginActivity.java:0)
                    at com.example.android.besecure.LoginActivity$5.&lt;init&gt;(LoginActivity.java:0)
                    at java.lang.reflect.Constructor.newInstance0(Native Method)
                    at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
                    at com.android.tools.fd.runtime.AndroidInstantRuntime.newForClass(AndroidInstantRuntime.java:191)
                    at com.example.android.besecure.LoginActivity$override.checkLogin(LoginActivity.java:107)
                    at com.example.android.besecure.LoginActivity$override.static$access$200(LoginActivity.java:27)
                    at com.example.android.besecure.LoginActivity$override.access$dispatch(LoginActivity.java)
                    at com.example.android.besecure.LoginActivity.access$200(LoginActivity.java:0)
                    at com.example.android.besecure.LoginActivity$1$override.onClick(LoginActivity.java:70)
                    at com.example.android.besecure.LoginActivity$1$override.access$dispatch(LoginActivity.java)
                    at com.example.android.besecure.LoginActivity$1.onClick(LoginActivity.java:0)
                    at android.view.View.performClick(View.java:5610)
                    at android.view.View$PerformClick.run(View.java:22265)
                    at android.os.Handler.handleCallback(Handler.java:751)
                    at android.os.Handler.dispatchMessage(Handler.java:95)
                    at android.os.Looper.loop(Looper.java:154)
                    at android.app.ActivityThread.main(ActivityThread.java:6077)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
  </code></pre>
  
  <p>The error appears in this line:</p>
  
  <pre><code>StringRequest stringRequest = new StringRequest(Request.Method.P ... )
  </code></pre>
  
  <p>I checked all the parameters of the constructor of StringRequst and neither of them is null. What could be the problem? Thanks!</p>