Accounts: update

需要授权

更新 GTM 帐号。立即试用查看示例

请求

HTTP 请求

PUT https://www.googleapis.com/tagmanager/v1/accounts/accountId

参数

参数名称 说明
路径参数
accountId string GTM 帐号 ID。
可选的查询参数
fingerprint string 此指纹(如果提供)必须与所存储账号的指纹匹配。

授权

此请求需要获得下列范围的授权(详细了解身份验证和授权)。

范围
https://www.googleapis.com/auth/tagmanager.manage.accounts

请求正文

在请求正文中,提供具有以下属性的 Accounts 资源

属性名称 说明 备注
可选属性
name string 账号的显示名称。 可写
shareData boolean 该账号是否以匿名方式与 Google 及其他各方共享数据。 可写

响应

如果成功,此方法将在响应正文中返回 Accounts 资源

示例

注意:此方法的代码示例并未列出所有受支持的编程语言(请参阅客户端库页面,查看受支持的语言列表)。

Java

使用 Java 客户端库

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

/*
 * This request updates an existing account for the authorized user.
 */

// Construct the account object
Account account = new Account();
account.setName("Primary GTM Account");
account.setShareData(false);

try {
  Account response = tagmanager.accounts().update("123456", account).execute();
} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      + e.getDetails().getCode() + " : "
      + e.getDetails().getMessage());
}

/*
 * The results of the update method are stored in the response object.
 * The following code shows how to access the updated name and fingerprint.
 */
System.out.println("Updated Name = " + response.getName());
System.out.println("Updated Fingerprint = " + response.getFingerprint());

Python

使用 Python 客户端库

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

# This request updates an existing account for the authorized user.
try:
  response = tagmanager.accounts().update(
      accountId='123456',
      body={
          'name': 'Primary GTM Account',
          'shareData': False
      }
  ).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 ('There was an API error : %s : %s' %
         (error.resp.status, error.resp.reason))

# The results of the update method are stored in the response object.
# The following code shows how to access the updated name and fingerprint.
print 'Updated Name = %s' % response.get('name')
print 'Updated Fingerprint = %s' % response.get('fingerprint')

试试看!

请使用下面的 API Explorer 对实时数据调用此方法并查看响应。