Container Versions: create

Yetkilendirme gerektirir

Kapsayıcı sürümü oluşturur. Hemen deneyin veya bir örneğe göz atın.

İstek

HTTP isteği

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

Parametreler

Parametre adı Değer Açıklama
Yol parametreleri
accountId string GTM Hesap Kimliği.
containerId string GTM Kapsayıcı Kimliği.

Yetkilendirme

Bu istek, aşağıdaki kapsamla yetkilendirme gerektirir (kimlik doğrulama ve yetkilendirme hakkında daha fazla bilgi edinin).

Kapsam
https://www.googleapis.com/auth/tagmanager.edit.containerversions

İstek içeriği

İstek gövdesinde, verileri aşağıdaki yapıyla sağlayın:

{
  "quickPreview": boolean,
  "name": string,
  "notes": string
}
Mülk adı Değer Açıklama Notlar
quickPreview boolean Bu sürüm, hızlı önizleme amaçlı olabilir ve kaydedilmemelidir.
name string Oluşturulacak kapsayıcı sürümünün adı.
notes string Oluşturulacak kapsayıcı sürümüyle ilgili notlar.

Yanıt

Başarılı olursa bu yöntem aşağıdaki yapıya sahip bir yanıt gövdesi döndürür:

{
  "containerVersion": accounts.containers.versions Resource,
  "compilerError": boolean
}
Mülk adı Değer Açıklama Notlar
containerVersion nested object Kapsayıcı sürümü oluşturuldu.
compilerError boolean Derleyici hataları olup olmaması.

Örnekler

Not: Bu yöntem için kullanıma sunulan kod örnekleri, desteklenen tüm programlama dillerini kapsamaz (Desteklenen dillerin listesi için istemci kitaplıkları sayfasını inceleyin).

Java

Java istemci kitaplığı'nı kullanmalıdır.

/*
 * 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 istemci kitaplığı'nı kullanır.

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

Deneyin.

Aşağıdaki API Gezgini'ni kullanarak canlı verilerde bu yöntemi çağırın ve yanıtı görün.