-1

Having a bit of problem with retrofit. I'm trying to get the data's from the below json :

{
  "items": [
    {
      "badge_counts": {
        "bronze": 127,
        "silver": 66,
        "gold": 16
      },
      "account_id": 448874,
      "is_employee": false,
      "last_modified_date": 1455447700,
      "last_access_date": 1461500578,
      "reputation_change_year": 87,
      "reputation_change_quarter": -79,
      "reputation_change_month": -79,
      "reputation_change_week": -100,
      "reputation_change_day": -100,
      "reputation": 3563,
      "creation_date": 1310583225,
      "user_type": "registered",
      "user_id": 843337,
      "accept_rate": 95,
      "website_url": "",
      "link": "http://stackoverflow.com/users/843337/the-crazy-chimp",
      "profile_image": "https://www.gravatar.com/avatar/67ea341bc00b31bef7a07ee236f32e3f?s=128&d=identicon&r=PG",
      "display_name": "The Crazy Chimp"
    }
  ],
  "has_more": false,
  "quota_max": 10000,
  "quota_remaining": 9872
}

But the returned list size is always 0. I don't know where is the problem exactly.

My Pojo classes :

ProfileData : http://hastebin.com/ebihiyufif.java

Item : http://hastebin.com/haquqazefi.java

BadgeCount : http://hastebin.com/zulojusayo.java

Interface :

 @GET("users/{ids}?order=desc&sort=reputation&site=stackoverflow")
    Call<ProfileData> getProfileDetails(@Path("ids") int id);

Part of activity class :

Retrofit retrofit = new Retrofit.Builder().baseUrl(Constants.BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .build();

    LoggedInUserQuestionApi loggedInUserQuestionApi = retrofit.create(LoggedInUserQuestionApi.class);
    loggedInUserQuestionApi.getProfileDetails(Integer.valueOf(id)).enqueue(new Callback<ProfileData>() {
        @Override
        public void onResponse(Response<ProfileData> response, Retrofit retrofit) {
            if (response.isSuccess()) {
                int size = response.body().getItems().size();
            }

        }

Any help is much appreciated. Thanks :)

Vivek_Neel
  • 1,343
  • 1
  • 14
  • 25

1 Answers1

0

Sorry, it was a silly mistake.

I just debugged it to see the id value and it was returning the default value from the getIntExtra which is 0.

user_id with 0 doesn't exist and Hence the list was empty

Vivek_Neel
  • 1,343
  • 1
  • 14
  • 25