Here is a simple http request that I make to my Django Rest Framework based API through Postman.

I send 4 simple parameters name, phone, password1 and password2 in form of form-data and expect the server to return a json object containing a key named key whose value is a JWT (JSON web token). This is working fine Postman, but whenever I try to do the same thing in my App through volley, I get 400 bad request error. I've tried doing multiple things but all in vain.
Can someone explain to me how to simply post some data in form of form-data in volley?
Here is my code.
public void signUp(View View) throws Exception
{
queue = Volley.newRequestQueue(this);
url = "http://<example>.com/auth/registration/";
Map<String,String> params = new HashMap<String, String>();
params.put("name","habc");
params.put("phone","0324423");
params.put("password1","pass");
params.put("password2","pass");
JsonObjectRequest add_user_request = new JsonObjectRequest(Request.Method.POST, url,new JSONObject(params),
new Response.Listener<JSONObject>()
{
@Override
public void onResponse(JSONObject response) {
try {
String key = response.getString("key");
tv.setText(key);
} catch (JSONException e) {
// Handle exception
}
}
},
new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error) {
// error.getStackTrace() doesnt print enough information
}
}
)
{
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String> params = new HashMap<String, String>();
params.put("Content-Type","application/x-www-form-urlencoded");
return params;
}
};
Toast.makeText(this,"Adding requst to queue . . ",Toast.LENGTH_SHORT).show();
queue.add(add_user_request);
queue.start();
}