Update an Uploaded HTML5 bundle

22 views
Skip to first unread message

Rc B

unread,
Nov 17, 2017, 10:58:46 AM11/17/17
to AdWords API Forum

hi

i'm using the AdGroupAdService service to create a template ad of HTML 5 bundle type 
i manage to create the ads (all sizes) but i need to find a way to update the content (due to some changes in the html)
can i do that using the api ? 


----

// here is the code i wrote for the create 
public long SaveHTMLTemplateAd(HTMLTemplateAdDetails Details)
        {
            var service = (AdGroupAdService)this.user.GetService(AdWordsService.v201708.AdGroupAdService);

            // TemplateAds 
            // types, fields names and more info can be found here:
            // note! beside each template type you can find its id, the supported dimensions and fields

            var templateAd = new TemplateAd()
            {                
                name = Details.Name,
                templateId = Details.TemplateId,
                finalUrls = new string[] { Details.URL },
                displayUrl = Details.URL,
                dimensions = new Dimensions() {
                    width = Details.Width,
                    height = Details.Height
                }
            };

            var mediaBundle = new MediaBundle()
            {
                data = Details.ZipFileContent,
                entryPoint = "index.html",
                type = MediaMediaType.MEDIA_BUNDLE
            };

            templateAd.templateElements = new TemplateElement[] {
                new TemplateElement() {
                    uniqueName = "adData",
                    fields = new TemplateElementField[] {
                        new TemplateElementField() {
                            name = "Custom_layout",
                            fieldMedia = mediaBundle,
                            type = TemplateElementFieldType.MEDIA_BUNDLE
                        },
                        new TemplateElementField() {
                            name = "layout",
                            fieldText = "Custom",
                            type = TemplateElementFieldType.ENUM
                        },
                    },
                }
            };

            var adGroupAd = new AdGroupAd
            {
                ad = templateAd,
                adGroupId = Details.AdGroupId
            };

            var operations = new AdGroupAdOperation[] {
                new AdGroupAdOperation {
                    @operator = Operator.ADD,
                    operand = adGroupAd                    
                }
            };
            
            var adGroupAdReturnValue1 = service.mutate(operations);
            return adGroupAdReturnValue1.value.First().ad.id;           
        }

------


thanks, Roby (-:

Jude Amagoh

unread,
Nov 17, 2017, 2:32:08 PM11/17/17
to AdWords API Forum
Hi, 

The Ad objects are immutable in AdWords. To modify an Ad, you will need to submit a REMOVE operation with the existing Ad and an ADD operation for a new Ad with the modified attributes. This creates a new Ad ID, so stats for the original Ad and the new Ad will appear under separate IDs in reports. Please check here for reference. You may not be able to update the contents of an HTML 5 bundle after uploading it. The MediaService is used to get an upload media bundles. This service does not have a mutate operation. Please note that the same behavior applies for the web interface as well. 

Best Regards,
Jude, AdWords API Team

Rc B

unread,
Nov 17, 2017, 5:30:58 PM11/17/17
to AdWords API Forum
thanks 
Reply all
Reply to author
Forward
0 new messages