Filtering account selection

20 views
Skip to first unread message

Vasco Moreira

unread,
Apr 29, 2024, 2:47:05 AM4/29/24
to Google Ads API and AdWords API Forum
Hello,

I'm trying to get a report with all active extension withing active account.

Before I can even get to the AdWordsApp.report() method I get an error:

Ca: Could not read from Google Ads at main (Code:25:25) at Object.<anonymous> (adsapp_compiled:20507:54)


function main() {

  var activeIds = [];
  var allAccountSelector = AdsManagerApp.accounts();
  var accountIterator = allAccountSelector.get();
  while (accountIterator.hasNext()) {
    var accounts = accountIterator.next();
    var hasImpressions = accounts.getStatsFor("LAST_30_DAYS");
    if (hasImpressions.getImpressions() > 0) {
      var accountId = accounts.getCustomerId();
      activeIds.push([accountId]);
    }
  }
  Logger.log(activeIds)
 
  var customerIds = activeIds.map(ids => '"' + ids.join("-") + '"');
 
  var accountSelector = AdsManagerApp.accounts().withIds(customerIds).get();
 
  while(accountSelector.hasNext()){
    var account = accountSelector.next();
    MccApp.select(account);
   
}}

i don't get an error when I define  accountSelector with the customerIds variable...

the error is prompted when I start the while loop... why?


Google Ads API Forum Advisor

unread,
Apr 29, 2024, 2:55:07 AM4/29/24
to adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

Based on the provided script snippet, I could see that you are using Google Ads Scripts. With this, I would recommend reaching out to the Google Ads Scripts support team as they are better equipped to address your concern. Please note that our team can only assist with the technical queries or concerns related to the Google Ads API.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02tIosG:ref" (ADR-00232960)

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages