1

i am trying to convert curl request into volley but i'm getting com.android.volley.AuthFailureError i have tried all the stack overflow answer but didn't helpful, i will be very thankful if someone help me what's i'm doing wrong.

curl: curl -X POST "http://API_ADDRESS/api/v1/Account/Login" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"username\": \"string\", \"password\": \"string\"}"

conversion to volley:

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

                        Log.d("ABC:",response);
                    }
                }, new Response.ErrorListener() {
                            @Override
                            public void onErrorResponse(VolleyError volleyError) {
                                Log.d("ABC",volleyError.toString());

                            }
                        }){


                    @Override
                    public Map<String, String> getParams() {
                        Map<String,String> params= new HashMap<>();
                        params.put("username","app");
                        params.put("password","tty_TTY_2020");
                        return params;

                    }

                    @Override
                    public Map<String, String> getHeaders() {
                        Map<String,String> headers= new HashMap<>();
                        headers.put("accept","application/json");
                        headers.put("Content-Type","application/json");
                        return headers;
                    }

                };
                queue.add(postRequest);

0 Answers0