0

I am just trying to send the Params in PostMethod and getting the 404 response. I have tried many solutions like this. But nothing has worked for me.

Here is my code what I actually tried..

    HashMap<String, String> headers = new HashMap<>();
                headers.put("value", phone);
                headers.put("type", "phone");
           VolleyHelperPost.callVolleyHelperPost(/*Constants.GET_MEMBERSHIP_ID*/"https://myUrl.org/forgotmembershipIDWeb?value="+""+phone+"&type=phone",
                        Constants.NOTIFICATION_GET_MEMBERSHIP_DETAILS,
                        this, headers, "");

and its implementation was 


 public static void callVolleyHelperPost(String requestUrl,
                                            final String reqRype,
                                            final Context context,
                                            final Map<String, String> bodyParams, String name) {


     StringRequest request = new StringRequest(Request.Method.POST, serverURL, new Response.Listener<String>() {
                            @Override
                            public void onResponse(String response) {

                                System.out.println("Success response:--->" + response);
                                if (progressDialog != null) {
                                    progressDialog.dismiss();
                                    progressDialog = null;
                                }
                                UserNotification.notify(reqRype, response);
                                UserNotification.notifyFragment(reqRype, response);
                            }
                        }, new Response.ErrorListener() {
                            @Override
                            public void onErrorResponse(VolleyError volleyError) {
        }


                        @Override
                        protected Map<String, String> getParams() throws AuthFailureError {
                            if (bodyParams != null) {
                                Log.d("params", "==========" + bodyParams.toString());
                                return bodyParams;
                            } else {
                                return super.getParams();
                            }
                        }
                        @Override
                        public String getBodyContentType() {
                            return application/json;
                        }
}

This is my postman Request enter image description here

basha
  • 587
  • 2
  • 6
  • 25

2 Answers2

0

You can use following to send Post request. No need to override getParams.

JsonObjectRequest jsonOblect = new JsonObjectRequest(Request.Method.POST, URL, new JSONObject(bodyParams), new Response.Listener<JSONObject>() {
.......
}
Zaid Mirza
  • 3,540
  • 2
  • 24
  • 40
0

You should append your params end of your url because your params are query params not a form params

so your url should be what you have on postman.

url is : "https://www.mayurl.org/forgotmembershipIDWeb?value"+your_value+"type="+your_type and remove your getParam() method

Rajasekaran M
  • 2,478
  • 2
  • 20
  • 30