error 400 using api

MBY6 years ago

this is android app code to create user
and i get error 400 :(

String url = "http://ip:8082/api/users";
        JSONObject js = new JSONObject();
        try {
            js.put("name", signup_name.getText().toString());
            js.put("email", signup_username.getText().toString());
            js.put("phone", signup_phone.getText().toString());
            js.put("password", signup_password.getText().toString());
            js.put("expirationTime", expirationTime);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        // Make request for JSONObject
        final JsonObjectRequest jsonObjReq = new JsonObjectRequest(
                Request.Method.POST, url, js,
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {
                        Toast.makeText(B_signup.this, "ثبت نام با موفقیت انجام شد", Toast.LENGTH_SHORT).show();
                        Intent intent=new Intent(B_signup.this,B_Login.class);
                        startActivity(intent);
                        B_signup.this.finish();
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(B_signup.this, "نام کاربری تکراری است !!!", Toast.LENGTH_SHORT).show();
            }
        }) {
           @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String,String> params = new HashMap<String, String>();
                // Removed this line if you dont need it or Use application/json
                params.put("Content-Type", "application/x-www-form-urlencoded");
                return params;
            }
        };
        Volley.newRequestQueue(this).add(jsonObjReq);
MBY6 years ago

there isn't anyone know about this error (error 400 bad request in api connection)????