Retrofit2 I do not receive content from the api

Viewed 16

I'm starting with retrofit2 and I only receive empty calls. I have been implementing the $Query part in an interface but I don't know if it is the correct way to receive information from the api that I am using.

interface part;

@GET("access_key=a2a158295f55407eb8f9b88a957a5bac&query={country}")
Call<CityAlternativa> getTemperature (@Query("country") String country);

MAIN part;

Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://api.weatherstack.com/")
.addConverterFactory(GsonConverterFactory.create())
.build();

interfaciciudad = retrofit.create(InterfaceCity.class);
Call<CityAlternativa> call = interfaciciudad.getTemperature(ciudad);
call.enqueue(new Callback<CityAlternativa>() {


@Override
public void onResponse(Call<CityAlternativa> call, Response<CityAlternativa> response)   {
CityAlternativa ciudadfinal = response.body();
int temp = ciudadfinal.getTemperature();
if (response != null){
mostrarCiudad.setText(temp);}
}
@Override
public void onFailure(Call<CityAlternativa> call, Throwable t) {
mostrarCiudad.setText("error en la lectura de datos");
Log.i("DINS DEL ERROR ",call.toString());
}
});
0 Answers
Related