Add a template ad with templateId=486 (Gmail custom HTML upload) into the ad group

64 views
Skip to first unread message

Hazar Hayat

unread,
Aug 10, 2015, 5:02:58 AM8/10/15
to AdWords API Forum
Hi can you tell me how to add a template ad with templateId=486 into the ad group using API.

I am trying it with API but i am having problem with setting the Custom_layout field.

I get the following error when creating a copy of existing template ad

AdGroupAdPage page = adGroupAdService.get(selector);
TemplateAd templateAd = adGroupAd.ad as TemplateAd;

TemplateAd templateAdNew = new TemplateAd();

//Update the url in the downloaded ads

templateAdNew.url = templateAd.url;
templateAdNew.finalUrls = templateAd.finalUrls;
templateAdNew.trackingUrlTemplate = templateAd.trackingUrlTemplate;
templateAdNew.displayUrl = templateAd.displayUrl;
templateAdNew.name = templateAd.name;
templateAdNew.templateElements = templateAd.templateElements;
templateAdNew.templateId = templateAd.templateId;
templateAdNew.adUnionId = templateAd.adUnionId;
templateAdNew.dimensions = templateAd.dimensions;


AdGroupAd textadGroupAd = new AdGroupAd();
textadGroupAd.adGroupId = adgroupId;
textadGroupAd.ad = templateAdNew;
textadGroupAd.status = adGroupAd.status;

AdGroupAdOperation adGroupAdOperation = new AdGroupAdOperation();
adGroupAdOperation.@operator = Operator.ADD;
adGroupAdOperation.operand = textadGroupAd;

adGroupAdService.mutate(new AdGroupAdOperation[] {adGroupAdOperation});

Request:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><RequestHeader xmlns="https://adwords.google.com/api/adwords/cm/v201502"><developerToken xmlns="https://adwords.google.com/api/adwords/cm/v201502">xxxx</developerToken><clientCustomerId xmlns="https://adwords.google.com/api/adwords/cm/v201502">xxxx</clientCustomerId><userAgent xmlns="https://adwords.google.com/api/adwords/cm/v201502">xxxx</userAgent></RequestHeader></soap:Header><soap:Body><mutate xmlns="https://adwords.google.com/api/adwords/cm/v201502"><operations><operator>ADD</operator><operand><adGroupId>19997049181</adGroupId><ad xsi:type="TemplateAd"><url>http://Hyundai.example.com</url><displayUrl>Hyundai.example.com</displayUrl><templateId>486</templateId><templateElements><uniqueName>adData</uniqueName><fields><name>multiDestinationUrl1</name><type>URL</type><fieldText>http://www.example.com/privacy</fieldText></fields><fields><name>actionUrl1</name><type>URL</type><fieldText>http://www.example.com/gsp/ukwid=4b9a156f-d0ab-41b2-b0e6-53d3b380dde7</fieldText></fields><fields><name>description</name><type>TEXT</type><fieldText>Find Hyundai Equus Specials &amp; Save!</fieldText></fields><fields><name>subject</name><type>TEXT</type><fieldText>Hyundai Equus Deals</fieldText></fields><fields><name>advertiser</name><type>TEXT</type><fieldText>car.com</fieldText></fields><fields><name>previewFileName</name><type>TEXT</type><fieldText>preview.jpg</fieldText></fields><fields><name>logoFileName</name><type>TEXT</type><fieldText>teaser.png</fieldText></fields><fields><name>Custom_layout</name><type>IMAGE</type><fieldMedia xsi:type="Image"><mediaId>1489628318</mediaId><referenceId>-8627339302394658816</referenceId><dimensions><key>FULL</key><value><width>0</width><height>0</height></value></dimensions><urls><key>FULL</key><value>https://tpc.googlesyndication.com/sadbundle/9819404771314892800/index.html</value></urls><sourceUrl>media://da/image?source=user_file&amp;id_from_source=GSP_Creative.zip&amp;operation=original</sourceUrl><name>GSP_Creative.zip</name><Media.Type>Image</Media.Type></fieldMedia></fields><fields><name>layout</name><type>ENUM</type><fieldText>Custom</fieldText></fields><fields><name>creationContext</name><type>TEXT</type><fieldText>WORKFLOW:BURDOCK,TEMPLATE_SOURCE:AD_GALLERY</fieldText></fields></templateElements><name>Display Ad created 8/5/15</name></ad><status>ENABLED</status></operand></operations></mutate></soap:Body></soap:Envelope>


Response:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201502"><requestId>00051c9e53e2d7780a814607d50f1ad7</requestId><serviceName>AdGroupAdService</serviceName><methodName>mutate</methodName><operations>0</operations><responseTime>528</responseTime></ResponseHeader></soap:Header><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>[AdError.EMPTY_FIELD @ operations[0].operand.ad.templateElements[0].fields[7].fieldMedia.assetPath; trigger:'&lt;null&gt;']</faultstring><detail><ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201502"><message>[AdError.EMPTY_FIELD @ operations[0].operand.ad.templateElements[0].fields[7].fieldMedia.assetPath; trigger:'&lt;null&gt;']</message><ApplicationException.Type>ApiException</ApplicationException.Type><errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AdError"><fieldPath>operations[0].operand.ad.templateElements[0].fields[7].fieldMedia.assetPath</fieldPath><trigger>&lt;null&gt;</trigger><errorString>AdError.EMPTY_FIELD</errorString><ApiError.Type>AdError</ApiError.Type><reason>EMPTY_FIELD</reason></errors></ApiExceptionFault></detail></soap:Fault></soap:Body></soap:Envelope>
Reply all
Reply to author
Forward
0 new messages