【发布时间】:2019-07-26 02:54:27
【问题描述】:
当我使用带有空格的城市调用 API 时,我得到一个空响应:例如“旧金山”。例如,当“墨西哥”工作正常时。
我尝试用“+”替换空格,但它在 android 中不起作用。但在邮递员中它起作用了。
这里是调用代码:
Api api = ApiBuilder.createApi();
Call<CurrentWeather> currentWeatherCall =
api.getCurrentWeather(API_KEY, "san+francisco", UNITS);
currentWeatherCall.enqueue(new Callback<CurrentWeather>() {
@Override
public void onResponse(Call<CurrentWeather> call,
Response<CurrentWeather> response) {
try {
Toast.makeText(getApplicationContext(), response.body().getCityName(),
Toast.LENGTH_SHORT).show();
}
【问题讨论】:
标签: android retrofit openweathermap