I'm trying to make GET request to some url - as result status response is 200 but response body is very strange - okhttp3.internal.http.RealResponseBody@84f1f6e. I have this result for any url("https://www.bbc.com/russia" is for example). Below is snapshot of my code:
val httpClient: OkHttpClient = OkHttpClient.Builder()
.addInterceptor(LoggingInterceptor())
.addNetworkInterceptor(StethoInterceptor())
.build()
fun runCheckQualityPeriodic() {
val request = Request.Builder()
.url("https://www.bbc.com/russia")
.build()
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
val response = httpClient.newCall(request).execute()
Logger.tag("krv").v("runCheckQualityPeriodic responce is " + response)
val body = response.body().toString()
Logger.tag("krv").v("runCheckQualityPeriodic responce body is " + body)
}
Below are screenshots from StethoInterceptor:
Do you have any idea why I receive such result?
toString() shows a developer-friendly representation. To get the actual content you need to change
response.body().toString()
to
response.body().string()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With