5

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)
chirag patel
  • 229
  • 4
  • 16
  • 1
    Did you find any fix for this? I am stuck with the same – gonephishing Jan 31 '19 at 11:27
  • 1
    check what parameters postman passed secretly in header. Add those parameters in header and it will work fine. – chirag patel Feb 01 '19 at 08:59
  • can you post the answer here @chiragpatel ? It will be of great help – CS Learner May 26 '20 at 04:08
  • The 5 parameters in header for me is Date, Content-Type, Content-Length, Connection, Server. Content-Type, Connection, Sever I am putting values as it is, for Date I am using the Calendar.My mainn problem comes with content-length. The content-length shown in Postman(527),the content-length I obtain using the getBytes("UTF-8") (167) and the content-length received by Android (64) are all different. When I hard code and send a content-length paramter as "64", it gives an AuthFailure Error again, with response code 401 – CS Learner May 26 '20 at 06:21
  • If I send any other content-length, other than 64, it gives an error com.android.volley.NoConnectionError: java.net.ProtocolException: content-length promised 167 bytes, but received 64 – CS Learner May 26 '20 at 06:23
  • 1
    Go to view->show postman console and check what parameters postman passing seretly. you have to pass it while sending request. it will work then after – chirag patel May 27 '20 at 17:32

0 Answers0