title: Handle an empty response in a JSONRequest with Volley
body: <p>I'm using <code>Volley</code> to make a <code>POST</code> request in my application, and in my case, a good response is a <code>201</code> with an empty body. I'm using a <code>JSONRequest</code>, to make the call.</p>
  
  <p>My problem is that the error response handler is getting called because response is empty. </p>
  
  <p>Below is my request:</p>
  
  <pre><code>    Request request = new JsonRequest&lt;Object&gt;(Request.Method.POST, url, body, new Response.Listener&lt;Object&gt;() {
  
          @Override
          public void onResponse(Object response) {
  
          }
      }, new ErrorListener(context)) {
  
          @Override
          protected Response&lt;Object&gt; parseNetworkResponse(NetworkResponse response) {
  
              Log.d(TAG, "success!!!!!!");
              if (response.statusCode == 201)
                  mListener.resetPasswordWasSent();
              return null;
          }
  
          @Override
          public Map&lt;String, String&gt; getHeaders() throws AuthFailureError {
              Map&lt;String,String&gt; params = new HashMap&lt;String, String&gt;();
              params.put("Content-Type","application/json");
              params.put("Accept", "application/json");
              return params;
          }
      };
  
      requestQueue.add(request);
  </code></pre>
  
  <p>My <code>parseNetworkResponse</code> function is getting called, then the <code>ErrorListener</code>, and the <code>onResponse</code> method never gets hits because I get a <code>NullPointerException</code> in the <code>ErrorListener</code>.</p>
  
  <p>I can ignore the <code>NullPointerException</code> in my error listener, but I'd prefer not to. Obviously, I can simply send my callback in the <code>parseNetworkResponse</code>, but I don't want to have any errors popping up. </p>
  
  <p>Anyone know how I should handle this?</p>
  
  <p><strong>Edit:</strong>
  Here is the stacktrace:</p>
  
  <pre><code>05-06 09:44:19.586  27546-27560/com.threepoundhealth.euco E/Volley﹕ [1830] NetworkDispatcher.run: Unhandled exception java.lang.NullPointerException
      java.lang.NullPointerException
      at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:126)
  </code></pre>