Create TextAd using Google AdWords Java API

16 views
Skip to first unread message

Suresh Kumar Shenbagam

unread,
Jul 25, 2019, 2:11:49 AM7/25/19
to AdWords API and Google Ads API Forum
Hi,

I am unable to create TextAd using Google AdWords JAVA API. Can anyone send me the java source to create the same.

Code:

TextAd textAd = new TextAd();
   textAd
.setHeadline("Test Headline");
   textAd
.setDescription1("Description1");
   textAd
.setDescription2("Description2");
   textAd
.setFinalUrls(new String[] {"http://cloudsense.com"});


AdGroupAdServiceInterface adGroupAdService =
        adWordsServices
.get(session, AdGroupAdServiceInterface.class);
AdGroupAd adGroupAd = new AdGroupAd();
                  adGroupAd
.setAdGroupId(adgroupid);
                  adGroupAd
.setAd(textAd);
                  adGroupAd
.setStatus("PAUSED");
AdGroupAdOperation adGroupAdOperation = new AdGroupAdOperation();
                  adGroupAdOperation
.setOperand(adGroupAd);
                  adGroupAdOperation
.setOperator(Operator.ADD);




   
AdGroupAdReturnValue result = adGroupAdService.mutate(adGroupAdOperation );




Am getting the following error:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   
<soap:Header>
       
<ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201809">
           
<requestId>00058e7b34c209b90aa78213c00de258</requestId>
           
<serviceName>AdGroupAdService</serviceName>
           
<methodName>mutate</methodName>
           
<operations>1</operations>
           
<responseTime>240</responseTime>
       
</ResponseHeader>
   
</soap:Header>
   
<soap:Body>
       
<soap:Fault>
           
<faultcode>soap:Client</faultcode>
           
<faultstring>[AdGroupAdError.CANNOT_CREATE_TEXT_ADS @ operations[0].operand.ad]</faultstring>
           
<detail>
               
<ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201809">
                   
<message>[AdGroupAdError.CANNOT_CREATE_TEXT_ADS @ operations[0].operand.ad]</message>
                   
<ApplicationException.Type>ApiException</ApplicationException.Type>
                   
<errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AdGroupAdError">
                       
<fieldPath>operations[0].operand.ad</fieldPath>
                       
<fieldPathElements>
                           
<field>operations</field>
                           
<index>0</index>
                       
</fieldPathElements>
                       
<fieldPathElements>
                           
<field>operand</field>
                       
</fieldPathElements>
                       
<fieldPathElements>
                           
<field>ad</field>
                       
</fieldPathElements>
                       
<trigger/>
                       
<errorString>AdGroupAdError.CANNOT_CREATE_TEXT_ADS</errorString>
                       
<ApiError.Type>AdGroupAdError</ApiError.Type>
                       
<reason>CANNOT_CREATE_TEXT_ADS</reason>
                   
</errors>
               
</ApiExceptionFault>
           
</detail>
       
</soap:Fault>
   
</soap:Body>
</soap:Envelope>


Suresh

Google Ads API Forum Advisor Prod

unread,
Jul 25, 2019, 3:38:43 AM7/25/19
to adwor...@googlegroups.com
Hi Suresh,

Could you try and create ExpandedTextAds instead? Since 2016, creation of standard TextAds was no longer supported in the AdWords API as discussed in this blog post from the same year.

Thanks and regards,
Peter
Google Ads API Team

ref:_00D1U1174p._5001UEGM1E:ref
Reply all
Reply to author
Forward
0 new messages