How to define accountName The resource name of the account that owns the collection of ad clients

87 Views Asked by At

I'm trying to use Adsense management API in Google Sheets using apps script which runs with javascript.

I'm unable to define "accountName " even knowing "This sample lists all of the ad clients for a given account. Specify the account as a resource name, for example, accounts/pub-12345."

documentation: https://developers.google.com/apps-script/advanced/adsense#list_ad_clients

Here is the code

`

enter code here`/**
 * Logs available Ad clients for an account.
 *
 * @param {string} accountName The resource name of the account that owns the
 *     collection of ad clients.
 */
function listAdClients(accountName) {
  let pageToken;
  do {
    const response = AdSense.Accounts.Adclients.list(accountName, {
      pageToken: pageToken
    });
    if (!response.adClients) {
      Logger.log('No ad clients found for this account.');
      return;
    }
    for (const adClient of response.adClients) {
      Logger.log('Found ad client for product "%s" with resource name "%s".',
          adClient.productCode, adClient.name);
      Logger.log('Reporting dimension ID: %s',
          adClient.reportingDimensionId ?? 'None');
    }
    pageToken = response.nextPageToken;
  } while (pageToken);
}
1

There are 1 best solutions below

0
Al Azad On

enter image description here

after declaring the function, add the accountName in the const response.