Retrofit Documentation says:
"By default, Retrofit can only deserialize HTTP bodies into OkHttp's ResponseBody...Converters can be added to support other types"
This implies I should be able to make a api call WIHTOUT using the GSON converter, and get my response in the form of a "ResponseBody" object.
but I still get error
java.lang.IllegalArgumentException: Unable to create converter for class com.squareup.okhttp.ResponseBody
here is my code
@GET("v1/search")
Call<ResponseBody> getArtists(@Query("q") String name, @Query("type") String searchType);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.spotify.com/")
.build();
api = retrofit.create(SpotifyApi.class);
api.getArtists(searchBox.getText().toString(), "artist")
.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
}
});
Basically for I want to be able to use Retrofit in its purest/simplest form and just get a basic/raw response back. this is not for a real app, it's for experimentation.
You need to use okhttp3.ResponseBody
from OkHttp 3.x (which Retrofit depends on). That error message indicates you are using the type from OkHttp 2.x.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With