title: How to get Volley POST response body?
body: <p>I am using simmilar fucntion for creating GET and POST api requests, but the GET function set textview to response body and I dont know how to read the status code and the POST function set textview to the response code and I dont know how to read response body. Can you help me, please?</p>
  
  <p>I also tried to log in parseNetworkResponse() response.data.toString() but thats is not the data that api returns. Maybe I need to encode it somehow?</p>
  
  <pre><code>public void createGet(Context context, String url) {
        final TextView apiResultTextview = (TextView) ((Activity) 
    context).findViewById(R.id.api_result_textview);
        // Instantiate the RequestQueue.
           RequestQueue queue = Volley.newRequestQueue(context);
  
      // Request a string response from the provided URL.
      StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
              new Response.Listener&lt;String&gt;() {
                  @Override
                  public void onResponse(String response) {
                      // Display the first 500 characters of the response string.
                      apiResultTextview.setText("Response is: " + response.substring(0, 50));
                  }
              }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
              apiResultTextview.setText(error.toString());
          }
      });
  
      // Add the request to the RequestQueue.
      queue.add(stringRequest);
  }
  
  public void createPost(Context context, String url, JSONObject body) {
      final TextView apiResultTextview = (TextView) ((Activity) context).findViewById(R.id.api_result_textview);
      RequestQueue requestQueue = Volley.newRequestQueue(context);
      final String mRequestBody = body.toString();
  
      StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener&lt;String&gt;() {
          @Override
          public void onResponse(String response) {
              Log.i("LOG_RESPONSE", response);
          }
      }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
              Log.e("LOG_RESPONSE", error.toString());
          }
      }) {
          @Override
          public String getBodyContentType() {
              return "application/json; charset=utf-8";
          }
  
          @Override
          public byte[] getBody() throws AuthFailureError {
              try {
                  return mRequestBody == null ? null : mRequestBody.getBytes("utf-8");
              } catch (UnsupportedEncodingException uee) {
                  VolleyLog.wtf("Unsupported Encoding while trying to get the bytes of %s using %s", mRequestBody, "utf-8");
                  return null;
              }
          }
  
          @Override
          protected Response&lt;String&gt; parseNetworkResponse(NetworkResponse response) {
              String responseString = "";
              if (response != null) {
                  responseString = String.valueOf(response.statusCode);
                  apiResultTextview.setText("Response is: " + responseString);
              }
              return Response.success(responseString, HttpHeaderParser.parseCacheHeaders(response));
          }
      };
      requestQueue.add(stringRequest);
  }
  </code></pre>