title: How to use POST request in android Volley library with params and header?
body: <p>I am trying to learn Volley library for posting data into webservices. I need to implement user registration form, following is the image of postman with parameters and header...
  <a href="https://i.stack.imgur.com/12b9R.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/12b9R.jpg" alt="postman screen for post request"></a></p>
  
  <p>now problem is, i am getting below error </p>
  
  <blockquote>
    <p>com.android.volley.ServerError</p>
  </blockquote>
  
  <p>this is my code for volley post method.</p>
  
  <pre><code>public void postNewComment(){
      try {
          RequestQueue requestQueue = Volley.newRequestQueue(this);
          String URL = "http://myurl/api/users";
          JSONObject jsonBody = new JSONObject();
          jsonBody.put("email", "test1@gmail.com");
          jsonBody.put("user_type", "C");
          jsonBody.put("company_id", "0");
          jsonBody.put("status", "A");
          jsonBody.put("password", "123456");
  
          final String requestBody = jsonBody.toString();
  
          StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, new Response.Listener&lt;String&gt;() {
              @Override
              public void onResponse(String response) {
                  Log.i("VOLLEY", response);
              }
          }, new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                  error.printStackTrace();
                  Log.e("VOLLEY", error.toString());
              }
          }) {
              @Override
              public String getBodyContentType() {
                  return "application/json; charset=utf-8";
              }
  
              @Override
              public Map&lt;String, String&gt; getHeaders() throws AuthFailureError {
                  final Map&lt;String, String&gt; headers = new HashMap&lt;&gt;();
                  headers.put("Authorization", "Basic " + "My_auth_key");
                  headers.put("Content-Type", "application/json");
  
                  return headers;
              }
  
              @Override
              protected Response&lt;String&gt; parseNetworkResponse(NetworkResponse response) {
                  String responseString = "";
                  if (response != null) {
                      responseString = String.valueOf(response.statusCode);
                      // can get more details such as response.headers
                  }
                  return Response.success(responseString, HttpHeaderParser.parseCacheHeaders(response));
              }
          };
  
          requestQueue.add(stringRequest);
      } catch (JSONException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>please suggest where am i getting wrong. URL is working correct with postman, also as you can see i need to set 2 headers. I also tried this Url post method with AsyncTask and its working good. Now i need to implement this using volley library. kindly suggest. thank you.    </p>
  
  <p>this is my logcat error:</p>
  
  <blockquote>
    <p>E/Volley: [81910] BasicNetwork.performRequest: Unexpected response code 405 for "Myurl"</p>
  </blockquote>