Paging Issue on V201509 API

66 views
Skip to first unread message

Senthil Palaniswami

unread,
Nov 3, 2015, 7:48:33 PM11/3/15
to AdWords API Forum
Team,

I am trying to get the Criteria data by using C# code. Below is my code to get the data by paging, problem is on the Paging. Total Record count is 189,000 , i have them assigned to get 10,000 records per pull, when i get into 100,000 as a startIndex , i get an error !!. Could you please assist on this issue ? Thanks


        try
        {
 
            // Check if the Client Customer ID has a value in it before fetching the data
            if(GAdWordsConfig.ClientCustomerId.Length >0)
            {
                // Get Critieia Service
                CampaignCriterionService GAdWordsCampaignCriterionService = (CampaignCriterionService)GAdWordsUser.GetService(AdWordsService.v201509.CampaignCriterionService);

                // Create the selector.
                Selector GAdWordsSelector = new Selector()
                {
                    fields = new string[] {Criterion.Fields.Id, Criterion.Fields.CriteriaType, CampaignCriterion.Fields.CampaignId},
                    predicates = new Predicate[] {
                    // Select only keywords.
                    Predicate.In(Criterion.Fields.CriteriaType,new string[] {"KEYWORD", "PLACEMENT"}),},
                    paging = Paging.Default
                };

                CampaignCriterionPage GAdWordsPage = new CampaignCriterionPage();

                do
                {
                    // Get the data from GoogleAdWords
                    GAdWordsPage = GAdWordsCampaignCriterionService.get(GAdWordsSelector);

                   if (GAdWordsPage != null && GAdWordsPage.entries != null)
                    {
                        int i = GAdWordsSelector.paging.startIndex;

                        foreach (CampaignCriterion adCampaignCriterion in GAdWordsPage.entries)
                        {
                                OutGAAdCriteriaBuffer.AddRow();
                                OutGAAdCriteriaBuffer.ClientCustomerID = GAdWordsConfig.ClientCustomerId.ToString().Trim();
                                OutGAAdCriteriaBuffer.AdCriteriaID = adCampaignCriterion.criterion.id.ToString().Trim();
                                OutGAAdCriteriaBuffer.AdCriteriaName = adCampaignCriterion.criterion.type.ToString().Trim();
                                OutGAAdCriteriaBuffer.AdCriteriaCampaignID = adCampaignCriterion.campaignId.ToString().Trim();
                                OutGAAdCriteriaBuffer.EndOfRowset();
                            i++;
                        } // For Each Ends
                    } // Check for records counts Ends
                   GAdWordsSelector.paging.IncreaseOffsetBy(10000);
                } // Do Ends
                while (GAdWordsSelector.paging.startIndex  < GAdWordsPage.totalNumEntries);

            } // If Client Customer check Ends !!



        } // Try Ends
        catch (Exception ex)
        {
            StreamWriter writer = new StreamWriter("c:\\GA_Groups_ErrorLog.txt");
            writer.WriteLine(ex.Message.ToString());
            writer.Close();
        } // Catch Ends
       

Umesh Dengale

unread,
Nov 4, 2015, 10:02:53 AM11/4/15
to AdWords API Forum
Hello,

In the AdWords API, when the start index of the request is 100,000 then SelectorError.START_INDEX_IS_TOO_HIGH error occurs. You could narrow the query as much as possible using predicates to avoid this limit when retrieving a large result set. Please check out our rate limit guide for more details.

Thanks,
Umesh, AdWords API Team.

Umesh Dengale

unread,
Nov 4, 2015, 2:20:06 PM11/4/15
to AdWords API Forum
Hello,

You could use the dateRange and filter an entity (eg. adgroup, campaign, criterion, ad etc) to limit the large result set. Please check the CampaignCriterionService.Selector for more details. 

Umesh Dengale

unread,
Nov 4, 2015, 5:07:53 PM11/4/15
to AdWords API Forum
Hello,

You could use the below Predicate.In for PLACEMENT.
Predicate.In(Criterion.Fields.CriteriaType,new string[] {"PLACEMENT"}),}, 
Please check out GetCampaignTargetingCriteria.cs C# example code from .NET client library.
Try to run commenting line Predicate.NotIn. If you get an error then please provide the detail error message and SOAP XML request and response. Just click Reply privately to author in the forum when responding.
Reply all
Reply to author
Forward
0 new messages