0

I know this question was already answered multiple times. But I still cannot figure out how to fix this in my code.

I'm using foursquare search api to get places.

This is my Retrofit interface:

public static final String API_URL ="https://api.foursquare.com/v2/";

 public interface getNearPlace {

    @GET("venues/search")
    Call <List<FoursquareSearch.response.venues>> searchResults(@Query("ll") String ll,@Query("oauth_token") String oauth_token,@Query("v") String v);
}

public static getNearPlace create() {
    return new Retrofit.Builder()
            .baseUrl(API_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .build()
            .create(FourSquareAPI.getNearPlace.class);
}
public class FoursquareSearch {

private response response;

public FoursquareSearch.response getResponse() {
    return response;
}

public class response {
    private List<venues> venues;
    public List<FoursquareSearch.response.venues> getVenues() {
        return venues;
    }
    public class venues {
        public String id;
        public String name;`
        public location location;
        public List<categories> categories;
        public Bitmap bitmap;
 }
}

I always get

Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $

error.

piyushj
  • 1,546
  • 5
  • 21
  • 29
MikeB
  • 257
  • 1
  • 4
  • 15

1 Answers1

0

It seems response is expected to be in JSONArray and you're getting it JSONObject. Try to debug the response and compare it.

jack
  • 129
  • 3