Je suis en train de comprendre comment fonctionne la modernisation, mais chaque fois que ma réponse est échoué J'ai même utilisé l'API GitHub mais ma réponse a échoué, ce que je fais quelque chose de mal Je suis tellement confusRéponse Retrofit Échec
Lien
http://api.openweathermap.org/data/2.5/weather?q=Spakane,Us&appid=api_key
classe Interface
@GET("data/2.5/weather")
Call<List<Weather>> getWeatherData(@Query("q") String cityName,@Query("appid") String apikey);
MainActivity
private final String BASE_URL = "http://api.openweathermap.org/";
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
RestApi api = retrofit.create(RestApi.class);
final Call<List<Weather>> weather = api.getWeatherData("rawalpindi",API_KEY);
final ProgressDialog pg = new ProgressDialog(this);
pg.setTitle("Downloading");
pg.setMessage("Please Wait .....");
pg.show();
weather.enqueue(new Callback<List<Weather>>() {
@Override
public void onResponse(Call<List<Weather>> call, Response<List<Weather>> response) {
pg.dismiss();
Log.d(TAG, "onResponse: "+response.isSuccessful());
Log.d(TAG, "onResponse: "+response.body().get(0).getClouds());
}
@Override
public void onFailure(Call<List<Weather>> call, Throwable t) {
Log.d(TAG, "onFailure: Failed :(");
Log.d(TAG, "onResponseFailed: "+call.request().url());
pg.dismiss();
}
});
Log
D/MainActivity: onFailure: Failed :(
D/MainActivity: onResponseFailed: http://api.openweathermap.org/data/2.5/weather?q=rawalpindi&appid=api_key
un message throwable
Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
impression throwable message d'erreur pour passer à travers le problème .. –
c'est le message throwable "" BEGIN_ARRAY EXPECTED était BEGIN_OBJECT à la ligne 1 colonne 2 $ path "" – Salman500
en double possible de [Retrofit 2 Android devrait BEGIN MATRICE mais était BEGIN OBJET à la ligne 1 colonne 2] (https://stackoverflow.com/questions/36177629/retrofit2-android-expected-begin-array-but-was-begin-object-at-line-1-column-2) –