Wymaga autoryzacji
Tworzy wersję kontenera. Wypróbuj lub zobacz przykład.
Prośba
Żądanie HTTP
POST https://www.googleapis.com/tagmanager/v1/accounts/accountId/containers/containerId/versions
Parametry
Nazwa parametru | Wartość | Opis |
---|---|---|
Parametry ścieżki | ||
accountId |
string |
Identyfikator konta Menedżera tagów Google. |
containerId |
string |
Identyfikator kontenera Menedżera tagów Google. |
Upoważnienie
To żądanie wymaga autoryzacji z tym zakresem (więcej informacji o uwierzytelnianiu i autoryzacji).
Zakres |
---|
https://www.googleapis.com/auth/tagmanager.edit.containerversions |
Treść żądania
Dane w treści żądania muszą mieć taką strukturę:
{ "quickPreview": boolean, "name": string, "notes": string }
nazwa usługi, | Wartość | Opis | Uwagi |
---|---|---|---|
quickPreview |
boolean |
Ta wersja została utworzona do szybkiego podglądu i nie powinna zostać zapisana. | |
name |
string |
Nazwa wersji kontenera do utworzenia. | |
notes |
string |
Uwagi dotyczące wersji kontenera do utworzenia. |
Odpowiedź
Jeśli operacja się uda, metoda zwróci odpowiedź w następującej strukturze:
{ "containerVersion": accounts.containers.versions Resource, "compilerError": boolean }
nazwa usługi, | Wartość | Opis | Uwagi |
---|---|---|---|
containerVersion |
nested object |
Wersja kontenera została utworzona. | |
compilerError |
boolean |
Błędy kompilatora. |
Przykłady
Uwaga: dostępne dla tej metody przykłady kodu nie odzwierciedlają wszystkich obsługiwanych języków programowania. Listę obsługiwanych języków znajdziesz na stronie z bibliotekami klienta.
Java
Korzysta z biblioteki klienta 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
Używa biblioteki klienta dla języka 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')
Wypróbuj
Użyj Eksploratora interfejsów API poniżej, aby wywołać tę metodę na aktywnych danych i zobaczyć odpowiedź.