title: How to send base64 string to server using volley
body: <p>I'm using volley library in android to call our server when try to send base64 encoded image to server the request fail but when remove the encoded string the request success without any issue.
  I use the following code to encode my image <br></p>
  
  <pre><code>  public static String imgToBase64(Bitmap bitmap) {
  ByteArrayOutputStream out = null;
  try {
    out = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 50, out);
    out.flush();
    out.close();
    byte[] imgBytes = out.toByteArray();
    return Base64.encodeToString(imgBytes, Base64.DEFAULT);
  } catch (Exception e) {
    return null;
  } finally {
    try {
      out.flush();
      out.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  </code></pre>
  
  <p>}</p>
  
  <p><br>and send request using volley with the following <br></p>
  
  <pre><code>public void sendDataToServer(final ApiResponse.Listener&lt;JSONObject&gt; listener, final ApiResponse.ErrorListener errorListener, String image) {
  String url = String.format(ASK, image);
  url = URLEncoder.encode(url);
  JsonRequest sendRequest = new JsonRequest(Request.Method.POST, url,
          new Response.Listener&lt;JSONObject&gt;() {
            @Override
            public void onResponse(JSONObject response) {
              listener.onResponse(response);
            }
          }, new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) {
      if (error != null) {
        if (error.networkResponse != null) {
          errorListener.onErrorResponse(error.networkResponse.statusCode, null);
        } else {
          errorListener.onErrorResponse(500, null);
        }
      }
    }
  });
  RequestPipeline.getInstance(mContext).addToRequestQueue(sendRequest);
  </code></pre>
  
  <p>}</p>