Container Versions: update

Cần có sự cho phép

Cập nhật phiên bản vùng chứa. Thử ngay hoặc xem ví dụ.

Yêu cầu

Yêu cầu HTTP

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

Các tham số

Tên thông số Giá trị Nội dung mô tả
Tham số đường dẫn
accountId string Mã tài khoản GTM.
containerId string Mã vùng chứa Trình quản lý thẻ của Google (GTM).
containerVersionId string Mã phiên bản vùng chứa Trình quản lý thẻ của Google (GTM).
Tham số truy vấn không bắt buộc
fingerprint string Khi được cung cấp, vân tay số này phải khớp với vân tay số của phiên bản vùng chứa trong bộ nhớ.

Ủy quyền

Yêu cầu này cần được uỷ quyền với phạm vi sau (đọc thêm về quy trình xác thực và uỷ quyền).

Phạm vi
https://www.googleapis.com/auth/tagmanager.edit.containerversions

Nội dung yêu cầu

Trong nội dung yêu cầu, hãy cung cấp tài nguyên Phiên bản vùng chứa có các thuộc tính sau:

Tên tài sản Giá trị Nội dung mô tả Ghi chú
Thuộc tính không bắt buộc
name string Tên hiển thị phiên bản vùng chứa. có thể ghi
notes string Ghi chú của người dùng về cách áp dụng phiên bản vùng chứa này trong vùng chứa. có thể ghi

Phản hồi

Nếu thành công, phương thức này sẽ trả về một tài nguyên Phiên bản vùng chứa trong nội dung phản hồi.

Ví dụ

Lưu ý: Các đoạn mã mẫu của phương thức này không phải là ví dụ cho mọi ngôn ngữ lập trình được hỗ trợ (xem trang thông tin về các thư viện dùng cho ứng dụng để biết danh sách các ngôn ngữ được hỗ trợ).

Java

Sử dụng thư viện ứng dụng Java.

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

/*
 * This request updates an existing container version.
 */

// Create the container version object.
ContainerVersion version = new ContainerVersion();
version.setName("Updated Container Version");
version.setNotes("This Container Version was updated.");

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

/*
 * The results of the update method are stored in the response object.
 * The following code shows how to access the updated name and fingerprint.
 */
System.out.println("Updated Name = " + response.getName());
System.out.println("Updated Fingerprint = " + response.getFingerprint());

Python

Dùng thư viện ứng dụng Python.

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

# This request updates an existing container version
try:
  response = tagmanager.accounts().containers().versions().update(
      accountId='123456',
      containerId='54321',
      containerVersionId='2',
      body={
          'name': 'Updated Container Version',
          'notes': 'This Container Version was updated.'
      }
  ).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 update method are stored in the response object.
# The following code shows how to access the updated name and fingerprint.
print 'Updated Name = %s' % response.get('name')
print 'Updated Fingerprint = %s' % response.get('fingerprint')

Hãy dùng thử!

Hãy sử dụng APIs Explorer bên dưới để gọi phương thức này trên dữ liệu trực tiếp và xem phản hồi.