I am currently in the process of upgrading to Retrofit v.2.0.0-beta1 and in the docs it says:
By default, Retrofit can only deserialize HTTP bodies into OkHttp's ResponseBody type and it can only accept its RequestBody type for @Body.
Converters can be added to support other types. Six sibling modules adapt popular serialization libraries for your convenience.
How exactly do I add a GSON converter so instead of RequestBody
I receive GSON.JsonObject
or GSON.JsonArray
for responses with Content-type: application/json
?
My initialization code looks like this:
OkHttpClient client = new OkHttpClient();
client.interceptors().add(new AuthInterceptor(authState));
client.interceptors().add(new LoggingInterceptor());
restClient = new Retrofit.Builder()
.client(client)
.baseUrl(BASE_URL)
.build()
.create(RestClient.class);