ต้องมีการให้สิทธิ์
สร้างเวอร์ชันคอนเทนเนอร์ ลองใช้เลยหรือดูตัวอย่าง
ส่งคำขอ
คำขอ HTTP
POST https://www.googleapis.com/tagmanager/v1/accounts/accountId/containers/containerId/versions
พารามิเตอร์
ชื่อพารามิเตอร์ | ค่า | คำอธิบาย |
---|---|---|
พารามิเตอร์เส้นทาง | ||
accountId |
string |
รหัสบัญชี GTM |
containerId |
string |
รหัสคอนเทนเนอร์ GTM |
การให้สิทธิ์
คำขอนี้ต้องได้รับสิทธิ์ด้วยขอบเขตต่อไปนี้ (อ่านเพิ่มเติมเกี่ยวกับการตรวจสอบสิทธิ์และการให้สิทธิ์)
ขอบเขต |
---|
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
/* * 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
# 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 ด้านล่างเพื่อเรียกใช้เมธอดนี้กับข้อมูลแบบเรียลไทม์และดูการตอบสนอง