Question

I can't seem to find anything in Retrofit docs regarding how to display any Request details.

Specifically, I want to see JSON from POST Request Body.

The problem is that my request to the server fails with no details message, and I suspect that something is wrong on my side.

Was it helpful?

Solution

Maybe there is a better way to achieve this, but you can configure your log level using the RestAdapter.Builder like:

   RestAdapter.Builder builder=...
   builder.setLogLevel(LogLevel.FULL).setLog(new RestAdapter.Log() {
            public void log(String msg) {
               Log.i("retrofit", msg);
            }
        });

OTHER TIPS

here is an updated answer for retrofit 2.0

 HttpLoggingInterceptor body = new HttpLoggingInterceptor();
        body.setLevel(HttpLoggingInterceptor.Level.BODY);
        builder.addInterceptor(body);

        OkHttpClient client = builder.build();

        retrofit = new Retrofit.Builder()
                .baseUrl(baseUrl)
                .client(client)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top