Android studio OpenWeatherAPI返回空值

Android studio OpenWeatherAPI返回空值,android-studio,retrofit,retrofit2,weather-api,openweathermap,Android Studio,Retrofit,Retrofit2,Weather Api,Openweathermap,我试图使用REFORMAT2和Gson从OpenWeatherAPI获取数据,但它总是返回空值错误 我尝试调试,返回的响应很好,但返回null 这是我的密码 POJO课程是从这里开始的。 我是多么努力地去争取 API接口 public interface Api { String api_key = "b6907d289e10d714a6e88b30761fae22"; String BASE_URL= "http://api.openweathermap.org/data/

我试图使用REFORMAT2和Gson从OpenWeatherAPI获取数据,但它总是返回空值错误

我尝试调试,返回的响应很好,但返回null

这是我的密码

POJO课程是从这里开始的。

我是多么努力地去争取

API接口

public interface Api {

    String api_key = "b6907d289e10d714a6e88b30761fae22";
    String BASE_URL= "http://api.openweathermap.org/data/2.5/";


   @GET("weather")
    Call<Weather> getWeather(@Query("lat") String latitude, @Query("lon") String longitude, @Query("appid") String api_key);


}
公共接口Api{
字符串api_key=“b6907d289e10d714a6e88b30761fae22”;
字符串BASE_URL=”http://api.openweathermap.org/data/2.5/";
@得到(“天气”)
调用getWeather(@Query(“lat”)字符串纬度、@Query(“lon”)字符串经度、@Query(“appid”)字符串api_键);
}
LoadWeather()

public void LoadWeather()
{
改装改装=新改装.Builder()
.baseUrl(Api.BASE\u URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
Api=改装.create(Api.class);
调用weatherCall=api.getWeather(“12.9716”,“77.5946”,api_键);
enqueue(新的回调函数(){
@凌驾
公共void onResponse(调用、响应){
Weather=response.body();
字符串temp=weather.getList().get(0.getMain().getTemp().toString();
日志d(标签“OnResponse:+天气);
}
@凌驾
失败时公共无效(调用调用,可丢弃的t){
}
});
}

您使用的应用程序密钥“b6907d289e10d714a6e88b30761fae22”用于 示例(示例.openweathermap.org)


您必须获得自己的API密钥。

是否可能忘记在URL中包含要使用的API? 也许你需要:

String BASE_URL= "http://api.openweathermap.org/data/2.5/weather?";

我用我自己的。我写它只是为了让人们可以从这个api中获得POJO类。您的代码显示您正在使用
b6907d289……
。您应该将问题中的代码修改为
String api\u key=“my\u api\u key”以避免混淆
String BASE_URL= "http://api.openweathermap.org/data/2.5/weather?";