I am getting null entries for ResponsiveSearchAd

30 views
Skip to first unread message

sameerseo...@gmail.com

unread,
Jul 17, 2018, 6:01:38 PM7/17/18
to AdWords API and Google Ads API Forum
Hi All,

I am getting null entries for ResponsiveSearchAd while retrieving search ads which is added for particular campaign or campaign group


Below is my code which i have written.

 List<string> CompaignIds = new List<string>();
            using (AdGroupAdService adGroupAdService = (AdGroupAdService)user.GetService(AdWordsService.v201806.AdGroupAdService))
            {
                // Create a selector to select all ads for the specified ad group.

               

                if (dtCamp.Rows.Count > 0)
                {
                    for (int j = 0; j < dtCamp.Rows.Count; j++)
                    {
                        CompaignIds.Add(Convert.ToString(dtCamp.Rows[j]["CampaignID"]));
                    }
                    //adGroupId = Convert.ToInt64(dtAdgroup.Rows[0]["AdGroupId"]);
                }
                
                Selector selector = new Selector()
                {
                    fields = new string[] { ResponsiveSearchAd.Fields.Id,
                                           // AdGroupAd.Fields.Status, 
                                            ResponsiveSearchAd.Fields.ResponsiveSearchAdHeadlines, 
                                            ResponsiveSearchAd.Fields.ResponsiveSearchAdDescriptions,
                                            ResponsiveSearchAd.Fields.ResponsiveSearchAdPath1,
                                            ResponsiveSearchAd.Fields.ResponsiveSearchAdPath2,
                                            ResponsiveSearchAd.Fields.DisplayUrl,
                                            ResponsiveSearchAd.Fields.Url
                    },
                    ordering = new OrderBy[] { OrderBy.Asc(ResponsiveSearchAd.Fields.Id) },
                    predicates = new Predicate[] {
                         Predicate.Equals("AdType", AdType.RESPONSIVE_SEARCH_AD.ToString()),
                        Predicate.In(AdGroup.Fields.CampaignId,CompaignIds.ToArray()),
                                                   },
                    paging = Paging.Default
                };

                AdGroupAdPage page = new AdGroupAdPage();

                try
                {
                    do
                    {
                        // Get the responsive search ads.
                        page = adGroupAdService.get(selector);

                        // Display the results.
                        if (page != null && page.entries != null)
                        {
                            int i = selector.paging.startIndex;

                            foreach (AdGroupAd adGroupAd in page.entries)
                            {
                                ResponsiveSearchAd expandedTextAd = (ResponsiveSearchAd)adGroupAd.ad;

                                DataRow[] drAdgrop = dtAdgroup.Select("AdGroupId='" + adGroupAd.adGroupId.ToString().Trim() + "'");
                                DataRow dr = dtCompaignAdsDetails.NewRow();

                                dr["AdsName"] = adGroupAd.ad;
                                dr["AdGroupId"] = adGroupAd.adGroupId;
                                dr["AdGroup"] = Convert.ToString(drAdgrop[0]["AdGroup"]);
                                dr["path1"] = expandedTextAd.path1;
                                dr["path2"] = expandedTextAd.path2;
                                dr["displayUrl"] = expandedTextAd.displayUrl;
                                dr["FinalURL"] = expandedTextAd.finalUrls;

                                //string str=adGroupAd.ad
                                dtCompaignAdsDetails.Rows.Add(dr);
                                i++;
                            }
                            dtCompaignAdsDetails.AcceptChanges();
                        }

                        selector.paging.IncreaseOffset();
                    } while (selector.paging.startIndex < page.totalNumEntries);
                    Console.WriteLine("Number of expanded text ads found: {0}", page.totalNumEntries);
                }
                catch (Exception e)
                {
                    throw new System.ApplicationException("Failed to get expanded text ads", e);
                }

            }

Regards,

Sunil Pandey,
    

Luis Xander Talag (AdWords API Team)

unread,
Jul 17, 2018, 10:21:15 PM7/17/18
to AdWords API and Google Ads API Forum
Hi Sunil,

To further investigate your issue, could you provide the complete SOAP request and response logs when you encountered the error as well as your clientCustomerId? Please reply via Reply privately to author.

Thanks and regards,
Luis
AdWords API Team
Reply all
Reply to author
Forward
0 new messages