Android webview POST request is failing with err_http_response_code_failure error but only for the first time. It works fine in all the subsequent retries. Not sure why it fails only for the first time after app launch. Any ideas? I have tried overriding onReceivedError but its not getting called.
AndroidView(
modifier = Modifier.fillMaxSize(),
factory = { context ->
WebView(context).apply {
settings.javaScriptEnabled = true
settings.domStorageEnabled = true
settings.loadWithOverviewMode = true
val myWebViewClient = object: WebViewClient() {
override fun onReceivedError(view: WebView?, request: WebResourceRequest, error: WebResourceError) {
showLoadingScreen = false
super.onReceivedError(view, request, error)
}
}
webViewClient = myWebViewClient
postUrl(url, body.toByteArray())
}
}, update = {
it.layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
) }
)