Search code examples
androidjsonretrofit2androidhttpclientokhttp

How to see request body in JSON format if Retrofit2 is used while sending POST call to API?


I am sending a POST request to server and my interface is this for Retrofit2 to convert it into JSON

public interface LoginService {

@POST("auth/signin")
@FormUrlEncoded
Call<CurrentUser> signin(
        @Field("email") String email,
        @Field("password") String password,
        @Field("device_os") String device_os,
        @Field("device_identity") String device_id
);

}

I want to see this request body in JSON format for the purpose of debugging.

Please help ! Thanks in advance .


Solution

  • check this answer

    You can use a logging interceptor for it.