BETA Experience: AdsApp.ads() selector throws error

79 views
Skip to first unread message

WCT

unread,
Sep 18, 2021, 4:55:16 AM9/18/21
to Google Ads Scripts Forum
Hi,

in BETA Experience the following piece of code 

  var adSelector = AdsApp.ads()
    .withCondition('CampaignId = "'+campaignId+'"')
    .withCondition('AdGroupId = "'+adGroupId+'"')
    .withCondition("Type IN [RESPONSIVE_SEARCH_AD]")
    .withCondition('Status = "ENABLED"');
  
  var adIterator = adSelector.get();

throws this error:

Exception: Call to GoogleAdsService.Search failed: The error code is not in this version. at adsapp_compiled:13606:120 at adsapp_compiled:13611:9 at pa (adsapp_compiled:210:15) at adsapp_compiled:218:20 at fB.search (adsapp_compiled:13696:28) at NA.search (adsapp_compiled:13339:19) at OA.search (adsapp_compiled:13420:20) at WA.search (adsapp_compiled:13504:19) at Vc (adsapp_compiled:975:34) at Vc.next (<anonymous>)

In the old scripting experience the code works fine.

How to fix?


thanks

Google Ads Scripts Forum Advisor

unread,
Sep 19, 2021, 11:04:50 PM9/19/21
to adwords...@googlegroups.com
Hi,

Thanks for reaching out. Harry here, from the Google Ads Scripts Team.

Kindly provide your Google Ads account ID and script's name so I can take a look closer at the issue you are encountering. You may send them here or privately via the reply to author option. Note that you may need to join the Google Group for you to use this option. If this option is not available at your end still, you may send it through our email (googleadsscr...@google.com) instead.
 
As a side note, if you're having trouble receiving replies from us, please check your Spam folder. Additionally, please add the 'From address' on that email to your contact list to ensure we aren't flagged as Spam in future messages. If you don't see a message from us in your Spam folder, please email us directly at googleadsscr...@google.com referring to this forum thread.
 
Looking forward to your reply.

Thanks,
Google Logo
Harry Cliford Rivera
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2NVJXt:ref

Google Ads Scripts Forum Advisor

unread,
Sep 23, 2021, 11:16:02 PM9/23/21
to adwords...@googlegroups.com
Hi,

Thanks for coming back. I couldn't seem to find the script in the provided Google Ads account, would you be able to double check this on our end and resend them? On the other hand, can you kindly try following code instead where I converted the fields to be more compatible with scripts beta? I'm assuming that the issue is that campaign and ad group IDs are not supported in the AdsApp.AdSelector.withCondition for beta and I believe they are replaced as resource names in GAQL reports. Please see Columns for your reference.
  var campaignId = "Campaign Name";
  var adGroupId = "Ad Group Name";
  var adSelector = AdsApp.ads()
    .withCondition('campaign.name = "'+campaignId+'"')
    .withCondition('ad_group.name = "'+adGroupId+'"')
    .withCondition("ad_group_ad.ad.type IN (RESPONSIVE_SEARCH_AD)")
    .withCondition('ad_group_ad.status = "ENABLED"');
  
  var adIterator = adSelector.get();
  while(adIterator.hasNext()) {
    var ad = adIterator.next();
    console.log(ad.getId());
  }
Reply all
Reply to author
Forward
0 new messages