401 Auth error while sending post request from Android App while working perfect in Postman

522 Views Asked by At

I am integrating exotel calling service in one of my clients android app. Api works fine in postman and receives xml response but it is not working in android app and gave volley 401 authentication error.

val stringRequest = object : StringRequest(Request.Method.POST,
                        URL,
                        Response.Listener { response ->
                            Toast.makeText(context, "response " + response.toString(), Toast.LENGTH_SHORT).show()
                            Log.d("Callresponse", response.toString())
                        }, Response.ErrorListener { error ->
                    Log.d("Callresponseerror", error.message.toString())
                    Toast.makeText(context, "error " + error.message, Toast.LENGTH_SHORT).show()
                }) {
                    override fun getParams(): MutableMap<String, String> {
                        val params = HashMap<String, String>()
                        params["From"] = AppSetting.getSitterMobile(context, AppConstants.PREF_MOBILE, null)
                        params["To"] = contact
                        params["CallerId"] = "*****"
                        params["CallType"] = "****"
                        return params
                    }
                }
                stringRequest.retryPolicy = DefaultRetryPolicy(10,
                        10,
                        DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)
                requestQueue.add(stringRequest)
0

There are 0 best solutions below