I am getting response body ** is okhttp3.internal.http.RealResponseBody@6e33b4c How to convert this to json or string.
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://mashape-community-urban-dictionary.p.rapidapi.com/define?term=check")
.get()
.addHeader("x-rapidapi-host", "mashape-community-urban-dictionary.p.rapidapi.com")
.addHeader("x-rapidapi-key", API)
.build();
Response response = client.newCall(request).execute();
Log.d("TAG", "response:toString() " + response.toString());
Log.d("TAG", "response:headers " + response.headers());
Log.d("TAG", "response:body " + response.body());
Log.d("TAG", "response:challenges " + response.challenges());
Log.d("TAG", "response:message " + response.message());
Log
response:toString() Response{protocol=http/1.1, code=200, message=OK, url=https://mashape-community-urban-dictionary.p.rapidapi.com/define?term=check}
response:headers Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json; charset=utf-8
Date: Mon, 13 Apr 2020 11:03:35 GMT
Server: RapidAPI-1.1.0
Via: 1.1 google
X-License: http://api.urbandictionary.com/
X-RapidAPI-Region: AWS - ap-southeast-1
X-RapidAPI-Version: 1.1.0
Content-Length: 4386
Connection: keep-alive
response:body okhttp3.internal.http.RealResponseBody@6e33b4c
response:challenges []
response:message OK
in RAPID API DEVELOPER DASHBOARD, I CAN SEE RESPONSE BODY How to convert it to string or JSON?
This would get the list in JSON
JSONObject object = new JSONObject(response.body().string());
final JSONArray array = object.getJSONArray("list");