private void GetGroups(IGroupsModel model, IMainPresenter presenter) { IMemberServices service = service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.GetGroupsUrl = ApplicationResource.ActionGetGroups; service.UserAgentVersion = ApplicationResource.UserAgent; IDataResponse response = service.GetGroups(new MemberData() { }, model.AccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (response.Data != null) { string data = response.Data.ToString(); dynamic jsonData = JsonConvert.DeserializeObject <dynamic>(data); // clear existing data first model.Groups.Clear(); int resultCount = jsonData["groups"].Count; for (int i = 0; i < resultCount; i++) { dynamic groups = jsonData["groups"][i]; dynamic groupName = groups["group_name"]; dynamic groupType = groups["group_management_type"][".tag"]; dynamic groupId = groups["group_id"]; dynamic memberCount = groups["member_count"]; // update model GroupListViewItemModel lvItem = new GroupListViewItemModel() { GroupName = groupName, GroupType = groupType, GroupId = groupId, MemberCount = memberCount }; model.Groups.Add(lvItem); } //if the group count is above limit - default 1000 we need to grab the cursor and call continue bool hasMore = jsonData["has_more"]; string cursor = jsonData["cursor"]; while (hasMore) { service.GetGroupsUrl = ApplicationResource.ActionGetGroupsContinuation; IDataResponse responseCont = service.GetGroups(new MemberData() { Cursor = cursor }, model.AccessToken); string dataCont = responseCont.Data.ToString(); dynamic jsonDataCont = JsonConvert.DeserializeObject <dynamic>(dataCont); int resultContCount = jsonDataCont["groups"].Count; for (int i = 0; i < resultContCount; i++) { dynamic groups = jsonDataCont["groups"][i]; dynamic groupName = groups["group_name"]; dynamic groupType = groups["group_management_type"][".tag"]; dynamic groupId = groups["group_id"]; dynamic memberCount = groups["member_count"]; // update model GroupListViewItemModel lvItem = new GroupListViewItemModel() { GroupName = groupName, GroupType = groupType, GroupId = groupId, MemberCount = memberCount }; model.Groups.Add(lvItem); } hasMore = jsonDataCont["has_more"]; cursor = jsonDataCont["cursor"]; } } } }