android-来自Foursquare的JSON请求后的空正文

android-来自Foursquare的JSON请求后的空正文,android,json,google-maps,retrofit,foursquare,Android,Json,Google Maps,Retrofit,Foursquare,我想搜索附近的场馆,并在谷歌地图上的每个附近场馆上添加一个标记。 为此,我使用Foursquare API和改型向服务器发出请求,但问题是我收到一个空正文作为响应 以下是我需要传入的参数: 基本URL: 我用于从以下位置请求JSON的接口: public interface FoursquareService { @GET("venues/search") Call<List<FoursquarePlaces>> getAllVenues(@Query("

我想搜索附近的场馆,并在谷歌地图上的每个附近场馆上添加一个标记。 为此,我使用Foursquare API和改型向服务器发出请求,但问题是我收到一个空正文作为响应

以下是我需要传入的参数:

基本URL:

我用于从以下位置请求JSON的接口:

public interface FoursquareService {
    @GET("venues/search")
    Call<List<FoursquarePlaces>> getAllVenues(@Query("client_id") String clientId,
                                              @Query("client_secret") String clientSecret,
                                              @Query("v") String date,
                                              @Query("ll") LatLng longitudeLatitude);
}
改装客户机:

retrofit = new Retrofit.Builder()
                .baseUrl("https://api.foursquare.com/v2/venues/search/")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
我在从JSON主体获取的位置上添加了一个标记:

public class FoursquarePlaces {
    private String name;
    private String city;
    private String category;
    private String longitude;
    private String latitude;
    private String address;

    public FoursquarePlaces() {
        this.name = "";
        this.city = "";
        this.setCategory("");
    }

    public void setCity(String city){
        if (city != null){
            this.city = city.replaceAll("\\(", "").replaceAll("\\)", "");
        }
    }

    public String getLongitude() {
        return longitude;
    }

    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }

    public String getLatitude() {
        return latitude;
    }

    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }
}
foursquareService = retrofit.create(FoursquareService.class);
        venuesLatLng = new LatLng(venuesLatitude, venuesLongitude);
        foursquareService.getAllVenues(Constants.FOURSQUARE_CLIENT_KEY,
                Constants.FOURSQUARE_CLIENT_SECRET, formatedDate, latLng).enqueue(new Callback<List<FoursquarePlaces>>() {
            @Override
            public void onResponse(Call<List<FoursquarePlaces>> call, Response<List<FoursquarePlaces>> response) {
               for (FoursquarePlaces place : response.body()) {
                   // I get the error here on response.body()
                    venuesLatitude = Integer.parseInt(place.getLatitude());
                    venuesLongitude = Integer.parseInt(place.getLongitude());
                    venuesMarker.position(venuesLatLng);
                    mMap.addMarker(venuesMarker);
                }
            }
            @Override
            public void onFailure(Call<List<FoursquarePlaces>> call, Throwable t) {

            }
        });
如果我计算表达式response.body(),我会得到:

但是我不明白,因为我给了它一个LatLng类型,为什么这不好,为什么我从服务器得到一个空的主体作为响应?

服务需要
ll
参数,格式为
XX.XX,YY.YY
。使用
LatLng
时,服务使用
LatLng.toString()
将参数格式化为
lat/lng:(46.7700381,23.55158)
,这是服务无法接受的

您可以将服务更改为接受
String
for
ll
参数:

public interface FoursquareService {
    @GET("venues/search")
    Call<List<FoursquarePlaces>> getAllVenues(@Query("client_id") String clientId,
                                              @Query("client_secret") String clientSecret,
                                              @Query("v") String date,
                                              @Query("ll") String longitudeLatitude); // <- here data type is changed
}
公共接口FoursquareService{
@获取(“场馆/搜索”)
调用getAllVinces(@Query(“client_id”)字符串clientId,
@查询(“客户端密码”)字符串clientSecret,
@查询(“v”)字符串日期,
@查询(“ll”)字符串的纵向相关性)//
foursquareService = retrofit.create(FoursquareService.class);
        venuesLatLng = new LatLng(venuesLatitude, venuesLongitude);
        foursquareService.getAllVenues(Constants.FOURSQUARE_CLIENT_KEY,
                Constants.FOURSQUARE_CLIENT_SECRET, formatedDate, latLng).enqueue(new Callback<List<FoursquarePlaces>>() {
            @Override
            public void onResponse(Call<List<FoursquarePlaces>> call, Response<List<FoursquarePlaces>> response) {
               for (FoursquarePlaces place : response.body()) {
                   // I get the error here on response.body()
                    venuesLatitude = Integer.parseInt(place.getLatitude());
                    venuesLongitude = Integer.parseInt(place.getLongitude());
                    venuesMarker.position(venuesLatLng);
                    mMap.addMarker(venuesMarker);
                }
            }
            @Override
            public void onFailure(Call<List<FoursquarePlaces>> call, Throwable t) {

            }
        });
java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference
errorDetail":"ll must be of the form XX.XX,YY.YY (received lat\/lng: (46.7700381,23.551585))
public interface FoursquareService {
    @GET("venues/search")
    Call<List<FoursquarePlaces>> getAllVenues(@Query("client_id") String clientId,
                                              @Query("client_secret") String clientSecret,
                                              @Query("v") String date,
                                              @Query("ll") String longitudeLatitude); // <- here data type is changed
}