Posting form-data Parameters in the body using Volley

前端 未结 1 803
自闭症患者
自闭症患者 2020-12-20 12:29

This is the Post Request done using postman

The response I want to get is :

    {
  \"result\": \"success\",
  \"reason\": {
    \"first_na         


        
相关标签:
1条回答
  • 2020-12-20 13:19

    Just try with below code this will use to send simple post data using volley, just replace URL and parameter data.

    StringRequest stringRequest = new StringRequest(Request.Method.POST, REGISTER_URL,
                        new Response.Listener<String>() {
                            @Override
                            public void onResponse(String response) {
                                Toast.makeText(MainActivity.this,response,Toast.LENGTH_LONG).show();
                            }
                        },
                        new Response.ErrorListener() {
                            @Override
                            public void onErrorResponse(VolleyError error) {
                                Toast.makeText(MainActivity.this,error.toString(),Toast.LENGTH_LONG).show();
                            }
                        }){
                    @Override
                    protected Map<String,String> getParams(){
                        Map<String,String> params = new HashMap<String, String>();
                        params.put(KEY_USERNAME,username);
                        params.put(KEY_PASSWORD,password);
                        params.put(KEY_EMAIL, email);
                        return params;
                    }
    
                };
    
                getRequestOtpPage().addToRequestQueue(stringRequest);
    
    0 讨论(0)
提交回复
热议问题