Q:

How to post raw data using volley?

I have following raw data which I need to send it to the server to get some response.
{
"nodeId": null,
"userId": null,
"mobileNumber": "0000000",
"emailId": "xxx@gmail.com",
"userProfile": null,
"region": null,
"countryCode": "01",
"password": "pass@123",
"places": [],
"trustedNetwork": [],
"profilePic": null,
"fullName": null,
"longitude": 0.0,
"latitude": 0.0  }

While posting the raw data I also have to send the authentication header parameters. Whatever I tried, I have not been able to post it.
I have used the following code which has not worked yet
RequestQueue requestQueue = Volley.newRequestQueue(getActivity());
    String URL = baseURL;

    final String mRequestBody = s;

    StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            Log.i("VOLLEY", response);
            new AlertDialog.Builder(getActivity())
                    .setTitle("hmm")
                    .setMessage(""+response)
                    .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();

                        }
                    })
                    .show();
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
         Log.e("VOLLEY", error.getLocalizedMessage());
            new AlertDialog.Builder(getActivity())
                    .setTitle("SORRY")
                    .setMessage(""+error.getLocalizedMessage())
                    .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();

                        }
                    })
                    .show();

        }
    }) {
        @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
        public Map<String, String> getHeaders() throws AuthFailureError {
            HashMap<String, String> headers = new HashMap<String, String>();
            String creds = String.format("%s:%s", "xxxxxx", "xxxxxxxxxxxxxx");
            String auth = "Basic " + Base64.encodeToString(creds.getBytes(), Base64.DEFAULT);
            headers.put("Authorization", auth);
            headers.put("Content-Type", "application/json; charset=utf-8");
            return headers;
        }

    };

    requestQueue.add(stringRequest);

A:

Here, the problem had actually occurred while creating authorization which brought up the volley exception case. Since, the password i was using was very long Base64.default was not handling it properly. After changing it to Base64.no_wrap, the problem was solved 

