title: In Volley library Header is not set to Content type text/plain
body: <pre><code>import android.app.ProgressDialog;
  import android.content.Context;
  import android.util.Log;
  import android.widget.Toast;
  
  import com.android.volley.AuthFailureError;
  import com.android.volley.Request;
  import com.android.volley.RequestQueue;
  import com.android.volley.Response;
  import com.android.volley.VolleyError;
  import com.android.volley.toolbox.StringRequest;
  import com.android.volley.toolbox.Volley;
  import com.google.gson.Gson;
  
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import java.io.UnsupportedEncodingException;
  import java.util.HashMap;
  import java.util.Map;
  
  
  public class LoginService {
  
  
      public interface VolleyCallback{
          void onSuccess(String result);
      }
  
      // method to call login webservice
      public void loginWebservice(final Context context, final ProgressDialog Dialog, final String username, final String password, final VolleyCallback callback) {
  
          Dialog.setMessage("Please wait..");
          Dialog.show();
          String POST_Login_URL = "http://example.com";
  
          StringRequest stringRequest = new StringRequest(Request.Method.POST, POST_Login_URL,
                  new Response.Listener&lt;String&gt;() {
                      @Override
                      public void onResponse(String response) {
                          Log.d("response", response);
                          Dialog.dismiss();
  
                          try {
                              JSONObject myJson = new JSONObject(response);
  
                              String authenticated = myJson.optString("status");
                              if (authenticated.equals("true")) {
                                  callback.onSuccess(authenticated);
  
                              } else {
                                  Toast.makeText(context, "Invalid Username/Password", Toast.LENGTH_LONG).show();
                              }
                          } catch (JSONException e) {
                              e.printStackTrace();
                          }
  
                      }
                  },
                  new Response.ErrorListener() {
                      @Override
                      public void onErrorResponse(VolleyError error) {
                          Dialog.dismiss();
                          Log.d("errorString", error.toString());
                          Toast.makeText(context, error.toString(), Toast.LENGTH_LONG).show();
  
                      }
                  }) {
  
              @Override
              public String getBodyContentType() {
                  return "text/plain; charset=" + getParamsEncoding();
  
  
              }
  
              @Override
              public Map&lt;String, String&gt; getHeaders() throws AuthFailureError {
                  HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                  map.put("Content-Type", "text/plain; charset="+ getParamsEncoding());
  
                  return map;
              }
  
              @Override
              public byte[] getBody() throws AuthFailureError {
  
                  try {
                      Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
  
                      params.put("username", username);
                      params.put("password", password);
                      String json = convert(params);
                      if (json.length() &lt; 3)
                          return ("{}").getBytes();
                      // log(json);
                      return json.getBytes(getParamsEncoding());
                  } catch (UnsupportedEncodingException e) {
                      Log.e("TAG", "getBody(): request has no json");
                      e.printStackTrace();
                  }
                  return new byte[0];
              }
  
          };
          RequestQueue requestQueue = Volley.newRequestQueue(context);
          requestQueue.add(stringRequest);
  
  
      }
  
      public static String convert(Map&lt;String, String&gt; map) {
          Gson gson = new Gson();
          String json = gson.toJson(map);
          return json;
      }
  }
  </code></pre>
  
  <p>In above code I am not able to update header content type application/json to text/plain. I override getBodyContentType() method and getHeaders() method but when I debug the code,content-type shows application/json i.e I am getting 500 error code from server. Web api is working fine. Because I checked the api by using my own network code.</p>