נדרשת הרשאה
יוצר גרסה של כלי קיבול. אפשר לנסות עכשיו או לראות דוגמה.
בקשה
בקשת HTTP
POST https://www.googleapis.com/tagmanager/v1/accounts/accountId/containers/containerId/versions
פרמטרים
שם הפרמטר | Value | התיאור |
---|---|---|
פרמטרים של נתיב | ||
accountId |
string |
מספר החשבון ב-GTM. |
containerId |
string |
מזהה מאגר התגים של GTM. |
הרשאות
בקשה זו מחייבת הרשאה בהיקף הבא (למידע נוסף על אימות והרשאה).
היקף |
---|
https://www.googleapis.com/auth/tagmanager.edit.containerversions |
גוף הבקשה
בגוף הבקשה, מספקים נתונים במבנה הבא:
{ "quickPreview": boolean, "name": string, "notes": string }
שם הנכס | Value | התיאור | הערות |
---|---|---|---|
quickPreview |
boolean |
יכול להיות שהיצירה של הגרסה הזו נועדה לתצוגה מקדימה מהירה ואין לשמור אותה. | |
name |
string |
שם הגרסה של כלי הקיבול שתיווצר. | |
notes |
string |
ההערות של גרסת כלי הקיבול שיש ליצור. |
תשובה
אם הפעולה בוצעה ללא שגיאות, השיטה הזו מחזירה גוף תגובה במבנה הבא:
{ "containerVersion": accounts.containers.versions Resource, "compilerError": boolean }
שם הנכס | Value | התיאור | הערות |
---|---|---|---|
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')
רוצה לנסות?
ניתן להשתמש ב-APIs Explorer שבהמשך כדי לקרוא לשיטה הזו בנתונים בזמן אמת ולראות את התגובה.