Accounts: list

इसके लिए, अनुमति लेना ज़रूरी है

यह डायलॉग बॉक्स उपयोगकर्ता के उन सभी GTM खातों की सूची बनाता है जिनका ऐक्सेस उपयोगकर्ता के पास है. इसे अभी आज़माएं या उदाहरण देखें.

अनुरोध

एचटीटीपी अनुरोध

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

अनुमति देना

इस अनुरोध के लिए, अनुमति देने के लिए इनमें से कम से कम एक दायरे की ज़रूरत होती है (पुष्टि करने और अनुमति देने के बारे में ज़्यादा पढ़ें).

स्कोप
https://www.googleapis.com/auth/tagmanager.readonly
https://www.googleapis.com/auth/tagmanager.manage.accounts
https://www.googleapis.com/auth/tagmanager.edit.containers

अनुरोध का मुख्य भाग

इस तरीके का इस्तेमाल करके, अनुरोध का मुख्य हिस्सा न दें.

जवाब

कामयाब होने पर, यह तरीका इस स्ट्रक्चर के साथ रिस्पॉन्स का मुख्य हिस्सा दिखाता है:

{
  "accounts": [
    accounts Resource
  ]
}
प्रॉपर्टी का नाम वैल्यू ब्यौरा ज़रूरी जानकारी
accounts[] list उन GTM खातों की सूची जिनका ऐक्सेस उपयोगकर्ता के पास है.

उदाहरण

ध्यान दें: इस तरीके के लिए दिए गए कोड के उदाहरणों में इसके साथ काम करने वाली सभी प्रोग्रामिंग भाषाएं नहीं दिखाई गई हैं (इसके साथ काम करने वाली भाषाओं की सूची के लिए क्लाइंट लाइब्रेरी वाला पेज देखें).

Java

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

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')

इसे आज़माएं!

इस तरीके को लाइव डेटा पर कॉल करने और रिस्पॉन्स देखने के लिए, नीचे दिए गए एपीआई एक्सप्लोरर का इस्तेमाल करें.