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,
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/978c2da8-e743-4bef-8adc-40c5d177d620%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.