Accounts: list

Richiede l'autorizzazione

Elenca tutti gli account GTM a cui un utente ha accesso. Prova subito o guarda un esempio.

Richiesta

Richiesta HTTP

GET https://www.googleapis.com/tagmanager/v1/accounts

Autorizzazione

Questa richiesta richiede l'autorizzazione con almeno uno dei seguenti ambiti (scopri di più su autenticazione e autorizzazione).

Ambito
https://www.googleapis.com/auth/tagmanager.readonly
https://www.googleapis.com/auth/tagmanager.manage.accounts
https://www.googleapis.com/auth/tagmanager.edit.containers

Corpo della richiesta

Non fornire il corpo di una richiesta con questo metodo.

Risposta

In caso di esito positivo, questo metodo restituisce un corpo della risposta con la seguente struttura:

{
  "accounts": [
    accounts Resource
  ]
}
Nome proprietà Valore Descrizione Note
accounts[] list Elenco di account GTM a cui un utente ha accesso.

Esempi

Nota: gli esempi di codice disponibili per questo metodo non rappresentano tutti i linguaggi di programmazione supportati (consulta la pagina relativa alle librerie client per un elenco dei linguaggi supportati).

Java

Utilizza la libreria client Java.

/*
 * Note: This code assumes you have an authorized tagmanager service object.
 */

/*
 * This request lists all accounts for the authorized user.
 */
try {
  ListAccountsResponse accounts = tagmanager.accounts().list().execute();
} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      + e.getDetails().getCode() + " : "
      + e.getDetails().getMessage());
}

/*
 * The results of the list method are stored in the accounts object.
 * The following code show how to iterate through them.
 */
for (Account account : accounts.getAccounts()) {
  System.out.println("Account Id = " + account.getAccountId());
  System.out.println("Account Name = " + account.getName());
  System.out.println("Account Share Data = " + account.getShareData());
  System.out.println("Account Fingerprint = " + account.getFingerprint());
}

Python

Utilizza la libreria client Python.

# Note: This code assumes you have an authorized tagmanager service object.

# This request lists all accounts for the authorized user.
try:
  accounts = tagmanager.accounts().list().execute()
except TypeError, error:
  # Handle errors in constructing a query.
  print 'There was an error in constructing your query : %s' % error

except HttpError, error:
  # Handle API errors.
  print dir(error)
  print ('There was an API error : %s : %s' %
         (error.resp.status, error.resp.reason))


# The results of the list method are stored in the accounts object.
# The following code shows how to iterate through them.
for account in accounts.get('accounts', []):
  print 'Account Id = %s' % account.get('accountId')
  print 'Account Name = %s' % account.get('name')
  print 'Account Share Data = %s' % account.get('shareData')
  print 'Account Fingerprint = %s' % account.get('fingerprint')

Prova.

Utilizza Explorer API di seguito per chiamare questo metodo sui dati in tempo reale e visualizzare la risposta.