Answer the question
In order to leave comments, you need to log in
How to get json from .gz file using Okhttp + Retrofit?
There is a data.json.gz file on the server
Inside a regular Json array with objects
[
{
"name": "name"
},
...
]
@Headers({
"Content-Type: application/json;charset=utf-8",
"Accept: application/json"
})
@GET("/data.json.gz")
Call<List<Data>> loader();
Retrofit retrofit;
iRequest iRequest;
Call<List<Data>> call;
Gson gson;
gson = new GsonBuilder()
.setLenient()
.create();
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(new OkHttpClient())
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
iRequest = retrofit.create(iRequest.class);
call = iRequest.loader();
java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
Answer the question
In order to leave comments, you need to log in
Obviously, there is no required header. Googled for you: https://stackoverflow.com/a/37370050
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question