Container Versions: create

認証が必要です

コンテナ バージョンを作成します。今すぐ試すまたは例を見る

リクエスト

HTTP リクエスト

POST https://www.googleapis.com/tagmanager/v1/accounts/accountId/containers/containerId/versions

パラメータ

パラメータ名 説明
パスパラメータ
accountId string GTM アカウント ID。
containerId string GTM コンテナ ID。

承認

このリクエストは、次のスコープでの承認が必要です(認証と承認の詳細をご確認ください)。

スコープ
https://www.googleapis.com/auth/tagmanager.edit.containerversions

リクエスト本文

リクエストの本文には、以下の構造を使用してデータを指定してください。

{
  "quickPreview": boolean,
  "name": string,
  "notes": string
}
プロパティ名 説明 メモ
quickPreview boolean クイック プレビュー向けに作成される場合もあるため、バージョンの保存はしないでください。
name string 作成するコンテナ バージョンの名前。
notes string 作成するコンテナ バージョンのメモ。

レスポンス

成功すると、このメソッドは次の構造を含むレスポンスの本文を返します。

{
  "containerVersion": accounts.containers.versions Resource,
  "compilerError": boolean
}
プロパティ名 説明 メモ
containerVersion nested object 作成されたコンテナ バージョン。
compilerError boolean コンパイラ エラーかどうか。

注: このメソッドで使用可能なコード例では、サポートされているプログラミング言語すべての例を示しているわけではありません(サポートされている言語の一覧については、クライアント ライブラリ ページをご覧ください)。

Java

Java クライアント ライブラリを使用します。

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

/*
 * This request creates a new container version.
 */

// Create the container versions options object.
CreateContainerVersionRequestVersionOptions options =
    new  CreateContainerVersionRequestVersionOptions();
options.setName("Container Version");
options.setNotes("Sample Container Version");
options.setQuickPreview(false);

try {
  CreateContainerVersionResponse response = tagmanager.accounts().
      containers().versions().create("123456", "54321", options).execute();
} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      + e.getDetails().getCode() + " : "
      + e.getDetails().getMessage());
}


/*
 * The results of the create method are stored in the response object.
 * The following code shows how to access the created id and fingerprint.
 */
System.out.println("Compiler Error = " + response.getCompilerError());
ContainerVersion version = response.getContainerVersion();
if (version != null) {
  System.out.println("Container Version Id = "
      + version.getContainerVersionId());
  System.out.println("Container Version Fingerprint = "
      + version.getFingerprint());
}

Python

Python クライアント ライブラリを使用します。

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

# This request creates a new container version.
try:
  response = tagmanager.accounts().containers().versions().create(
      accountId='123456',
      containerId='54321',
      body={
          'name': 'Container Version',
          'notes': 'Sample Container Version',
          'quickPreview': True
      }
  ).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 create method are stored in response object.
# The following code shows how to access the created id and fingerprint.
version = response.get('containerVersion', {})
print 'Container Version Id = %s' % version.get('containerVersionId')
print 'Container Version Fingerprint = %s' % version.get('fingerprint')

試してみよう:

以下の API Explorer を使用して、ライブデータに対してこのメソッドを呼び出し、レスポンスを確認してください。