getCriterionBidLandscape Paging Problem

115 views
Skip to first unread message

gabriel....@gmail.com

unread,
Oct 15, 2013, 10:25:11 AM10/15/13
to adwor...@googlegroups.com, Marcelo Lichtenstein
Hi,

I am trying to paginate the results of the getCriterionBidLandscape operation of the Data Service, however the totalNumEntries returned by the CriterionBidLandscapePage is not correct.

I am using the .net client library and the version v201306 of the API.

Bellow I paste part of my code.

Any help will be appreciated.

Thanks in advance,
Gabriel

            // Gets the DataService
            DataService dataService = (DataService)user.GetService(AdWordsService.v201306.DataService);
 
            // Creates the selector.
            Selector selector = new Selector();
            selector.fields = new string[] { "CampaignId""StartDate""EndDate""LocalImpressions""LocalClicks""LocalCost""Bid""MarginalCpc" };
 
            // Creates the predicate to filter the bid lanscapes for the selected keywords
            Predicate criterionPredicate = new Predicate();
            criterionPredicate.field = "CriterionId";
            criterionPredicate.@operator = PredicateOperator.IN;
            criterionPredicate.values = adGroupCriterionPage.entries.Select(k => k.criterion.id.ToString()).ToArray();
 
            selector.predicates = new Predicate[] { adGroupPredicate, criterionPredicate };
 
            // Creates paging controls
            selector.paging = new Paging();
            selector.paging.startIndex = 0;
            selector.paging.numberResults = 10000;
 
            CriterionBidLandscapePage criterionBidLandscapePage = null;
            do
            {
                try
                {
                    // Gets bid landscapes for the selected keywords
                    criterionBidLandscapePage = dataService.getCriterionBidLandscape(selector);
 
                    // Use criterionBidLandscapePage entries data
                }
                catch (Exception ex)
                {
                    // Handle Error
                }
 
                selector.paging.startIndex += 10000;
            } 
            while (criterionBidLandscapePage.totalNumEntries > selector.paging.startIndex);

Takeshi Hagikura (AdWords API Team)

unread,
Oct 18, 2013, 12:40:04 AM10/18/13
to adwor...@googlegroups.com, Marcelo Lichtenstein
Hi Gabriel,

Thanks for the report. 
Can you please also share the request and response SOAP xml logs to see what the returned totalNumEntries is?
(Please remove the sensitive info)

Best,
- Takeshi, AdWords API Team

Josh Radcliff (AdWords API Team)

unread,
Oct 28, 2013, 10:25:28 AM10/28/13
to adwor...@googlegroups.com, Marcelo Lichtenstein
Hi Gabriel,

Could you share the information Takeshi requested below?  Please make sure you remove any sensitive information from the logs before you post.

Cheers,
Josh, AdWords API Team

gabriel....@gmail.com

unread,
Oct 28, 2013, 5:07:22 PM10/28/13
to adwor...@googlegroups.com, Marcelo Lichtenstein
Hi guys,

Thanks for your replies.

Please find attached the SOAP xml logs of the getCriterionBidLandscape API call.

Cheers,
Gabriel
soap_xml.log

Josh Radcliff (AdWords API Team)

unread,
Oct 30, 2013, 12:06:45 PM10/30/13
to adwor...@googlegroups.com, Marcelo Lichtenstein
Hi Gabriel,

Thanks for sending over the logs.  I see what you're saying - this is odd indeed.

While I'm investigating, could you work around this by limiting the number of ad groups or campaigns per request?  As long as the number of landscape points for your criteria is less than the numberResults on the request's paging element you will get back all of the results in a single response/page.

Thanks,
Josh, AdWords API Team

gabriel....@gmail.com

unread,
Oct 31, 2013, 10:12:15 AM10/31/13
to adwor...@googlegroups.com, Marcelo Lichtenstein
Hi Josh,

Thanks for your reply.

Meanwhile, we will use that workaround.

Please let us know if you have any news.

Best,
Gabriel

Josh Radcliff (AdWords API Team)

unread,
May 21, 2014, 12:05:25 PM5/21/14
to adwor...@googlegroups.com, Marcelo Lichtenstein
Hi Gabriel,

Due to the manner in which bid landscapes are retrieved it is not feasible to change the behavior of paging for this service. However, to try to make the behavior clearer to API users I coordinated an update to the service documentation, adding:

In the result, the returned LandscapePoints are grouped into CriterionBidLandscapes by their criteria, and numberResults of paging limits the total number of LandscapePoints instead of number of CriterionBidLandscapes.

Put another way, to ensure you are consuming all of the pages and results, you should:
  • Ignore the totalNumEntries value in the response
  • On each subsequent request, increment Paging.startIndex by Paging.numberResults
  • Keep submitting requests for subsequent pages until you get back an empty page
Cheers,
Josh, AdWords API Team
Reply all
Reply to author
Forward
0 new messages