نیاز به مجوز دارد
یک ظرف را به روز می کند. اکنون آن را امتحان کنید یا نمونه ای را ببینید .
درخواست
درخواست HTTP
PUT https://www.googleapis.com/tagmanager/v1/accounts/accountId/containers/containerId
مولفه های
نام پارامتر | ارزش | شرح |
---|---|---|
پارامترهای مسیر | ||
accountId | string | شناسه حساب GTM. |
containerId | string | شناسه کانتینر GTM. |
پارامترهای پرس و جو اختیاری | ||
fingerprint | string | در صورت ارائه، این اثر انگشت باید با اثر انگشت ظرف موجود در انبار مطابقت داشته باشد. |
مجوز
این درخواست به مجوز با محدوده زیر نیاز دارد ( در مورد احراز هویت و مجوز بیشتر بخوانید ).
محدوده |
---|
https://www.googleapis.com/auth/tagmanager.edit.containers |
درخواست بدن
در بدنه درخواست، یک منبع Containers با ویژگی های زیر ارائه کنید:
نام ملک | ارزش | شرح | یادداشت |
---|---|---|---|
خواص مورد نیاز | |||
usageContext[] | list | فهرست زمینه های استفاده برای کانتینر. مقادیر معتبر عبارتند از: web, android, ios . | قابل نوشتن |
ویژگی های اختیاری | |||
domainName[] | list | لیست اختیاری نام های دامنه مرتبط با کانتینر. | قابل نوشتن |
enabledBuiltInVariable[] | list | لیست متغیرهای داخلی فعال شده Valid values in pageUrl, pageHostname, pagePath, referrer, event, clickElement, clickClasses, clickId, clickTarget, clickUrl, clickText, formElement, formClasses, formId, formTarget, formUrl, formText, errorMessage, errorUrl, errorLine, newHistoryFragment, oldHistoryFragment, newHistoryState, oldHistoryState, historySource, containerVersion, debugMode, randomNumber, containerId . | قابل نوشتن |
name | string | نام نمایشی کانتینر | قابل نوشتن |
notes | string | یادداشت های ظرف. | قابل نوشتن |
timeZoneCountryId | string | شناسه کشور کانتینر. | قابل نوشتن |
timeZoneId | string | شناسه منطقه زمانی کانتینر. | قابل نوشتن |
واکنش
در صورت موفقیت آمیز بودن، این روش یک منبع Containers را در بدنه پاسخ برمی گرداند.
مثال ها
توجه: نمونههای کد موجود برای این روش همه زبانهای برنامهنویسی پشتیبانیشده را نشان نمیدهند (برای فهرست زبانهای پشتیبانیشده به صفحه کتابخانههای سرویس گیرنده مراجعه کنید).
جاوا
از کتابخانه سرویس گیرنده جاوا استفاده می کند.
/* * Note: This code assumes you have an authorized tagmanager service object. */ /* * This request updates an existing container for the authorized user. */ // Construct the container object. Container container = new Container(); container.setName("Example Container"); container.setNotes("Example Container Notes."); container.setTimeZoneCountryId("US"); container.setTimeZoneId("America/Los_Angeles"); container.setUsageContext(Arrays.asList("web", "android", "ios")); try { Container response = tagmanager.accounts(). containers().update("123456", "54321", container).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());
پایتون
از کتابخانه کلاینت پایتون استفاده می کند.
# Note: This code assumes you have an authorized tagmanager service object. # This request updates an existing container. try: response = tagmanager.accounts().containers().update( accountId='123456', containerId='54321', body={ 'name': 'Example Container', 'timeZoneCountryId': 'US', 'timeZoneId': 'America/Los_Angeles', 'usageContext': ['web', 'android'] } ).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')
آن را امتحان کنید!
از APIs Explorer زیر برای فراخوانی این روش در دادههای زنده و دیدن پاسخ استفاده کنید.