Container Versions: create

يجب تقديم تفويض

تنشئ إصدار حاوية. جرِّبه الآن أو شاهد مثالاً.

الطلب

طلب HTTP

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

المَعلمات

اسم المعلَمة القيمة الوصف
مَعلمات المسار
accountId string رقم تعريف حساب "إدارة العلامات من Google".
containerId string رقم تعريف حاوية Google Tag Manager

التفويض

يتطلب هذا الطلب تفويضًا من خلال النطاق التالي (مزيد من المعلومات حول المصادقة والترخيص).

النطاق
https://www.googleapis.com/auth/tagmanager.edit.containerversions

نص الطلب

في نص الطلب، يمكنك توفير البيانات بالبنية التالية:

{
  "quickPreview": boolean,
  "name": string,
  "notes": string
}
اسم الموقع القيمة الوصف Notes
quickPreview boolean قد يكون إنشاء هذا الإصدار للمعاينة السريعة ولا يجب حفظه.
name string اسم إصدار الحاوية المطلوب إنشاؤه.
notes string ملاحظات إصدار الحاوية المطلوب إنشاؤه.

الإجابة

في حال نجاحها، تعرض هذه الطريقة نص استجابة بالبنية التالية:

{
  "containerVersion": accounts.containers.versions Resource,
  "compilerError": boolean
}
اسم الموقع القيمة الوصف Notes
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')

تجربة

يمكنك استخدام مستكشف واجهات برمجة التطبيقات أدناه لطلب هذه الطريقة على البيانات المباشرة والاطّلاع على الاستجابة.