【发布时间】:2015-11-12 10:29:55
【问题描述】:
我需要记录我的服务器在调用后发送的响应,因为我收到了 MalformedJsonException,以查看发生了什么。
我正在使用此代码:
OkHttpClient client = new OkHttpClient();
client.interceptors().add(new Interceptor() {
@Override
public com.squareup.okhttp.Response intercept(Chain chain) throws IOException {
com.squareup.okhttp.Response respuesta = chain.proceed(chain.request());
Log.i("David", "Response: "+respuesta.toString());
return response;
}
});
Retrofit builder = new Retrofit.Builder()
.baseUrl(url)
.addConverterFactory(GsonConverterFactory.create())
.build()
.client(client);
我按照this 教程完成了这个。我在 ".client(client); line: "client() in Retrofit cannot be applied to (com.squareup.okhttp.OkHttpClient) 中收到错误
我做错了什么?我需要做什么来拦截来自服务器的响应,看看 JSON 有什么问题?
谢谢。
【问题讨论】: