Hi, I believe the second argument to the Paging constructor is the number of results you want, not the last index to return. Try just passing PAGE_SIZE instead of offset + PAGE_SIZE as the second argument.
- Kevin Winter AdWords API Team On Thursday, August 16, 2012 1:52:15 AM UTC-4, jerryhouse wrote: > > I tried to get the adgroup by adwords java api with the code below: > > List<AdGroup> adGroups = new LinkedList<AdGroup>(); > adGroups = new LinkedList<AdGroup>(); > AdGroupServiceInterface gs = ServiceFactory.getAdGroupService(); > // Create selector. > Selector selector = new Selector(); > String[] fields = AdwordsFieldUitl.getAdGroupField(); > selector.setFields(fields); > Predicate p = new Predicate("Status", PredicateOperator.IN, new > String[]{"ENABLED"}); > selector.setPredicates(new Predicate[]{p}); > selector.setPaging(new Paging(0, PAGE_SIZE)); > try { > AdGroupPage page = gs.get(selector); > int offset = 0; > while (offset < page.getTotalNumEntries()) { > for (AdGroup g : page.getEntries()) > adGroups.add(g); > offset += PAGE_SIZE; > selector.setPaging(new Paging(offset, offset + PAGE_SIZE)); > } > } catch (ApiException e) { > e.printStackTrace(); > } catch (RemoteException e) { > e.printStackTrace(); > } > return adGroups; > When I check the results, I am so confused that there are many adgroup > records has the same id and other contents, shouldn't the id of the adgroup > be unique for each different adgroups? > -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://adwordsapi.blogspot.com http://groups.google.com/group/adwords-api =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en