Creating a Text Ad with SOAPUI

175 views
Skip to first unread message

srohde

unread,
Jun 23, 2016, 2:26:44 PM6/23/16
to AdWords API Forum
I'm trying to figure out how to create a text ad form SOAPUI. I get the following validation errors...



...and the following API response...

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>Unmarshalling Error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'v20:headline'. One of '{
'is expected.</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>


...when I submit this request...

  1. <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v20="https://adwords.google.com/api/adwords/cm/v201605">
  2.    <soapenv:Header>
  3.       <v20:RequestHeader>
  4.          <v20:clientCustomerId>[redacted]<</v20:clientCustomerId>
  5.          <v20:developerToken>[redacted]</v20:developerToken>
  6.          <v20:validateOnly>false</v20:validateOnly>
  7.          <v20:partialFailure>false</v20:partialFailure>
  8.       </v20:RequestHeader>
  9.    </soapenv:Header>
  10.    <soapenv:Body>
  11.       <v20:mutate>
  12.          <v20:operations>
  13.             <v20:operator>ADD</v20:operator>
  14.             <v20:operand>
  15.                <v20:adGroupId>[redacted]<</v20:adGroupId>
  16.                <v20:ad>
  17.                   <v20:displayUrl>example.com</v20:displayUrl>
  18.                   <v20:finalUrls>http://www.example.com</v20:finalUrls>
  19.                   <v20:type>TEXT_AD</v20:type>
  20.                   <v20:devicePreference>30001</v20:devicePreference>
  21.                   <v20:Ad.Type>TextAd</v20:Ad.Type>
  22.                   <v20:headline>Summer things</v20:headline>
  23.                   <v20:description1>Get things for summer</v20:description1>
  24.                   <v20:description2>while the prices are low.</v20:description2>
  25.                </v20:ad>
  26.                <v20:status>ENABLED</v20:status>
  27.             </v20:operand>
  28.          </v20:operations>
  29.       </v20:mutate>
  30.    </soapenv:Body>
  31. </soapenv:Envelope>

It seems that the order of the ad element has something to do with it because the error messages change when I re-order the ad elements.  

Any suggestions?

Thanks!

Shwetha Vastrad (AdWords API Team)

unread,
Jun 23, 2016, 6:02:34 PM6/23/16
to AdWords API Forum
Hi,

To create a Text ad, you need to use xsi:type to specify the AdType as this field is ignored on input. A sample mutate element to add a TextAd looks like this:

    <soapenv:Body>
            <operations>
                <operator>ADD</operator>
                <operand>
                    <adGroupId>AdGroupID</adGroupId>
                    <ad xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201605" xsi:type="ns2:TextAd">
                        <ns2:displayUrl>YOUR_DISPLAY_URL</ns2:displayUrl>
                        <ns2:finalUrls>YOUR_FINAL_URL</ns2:finalUrls>
                        <ns2:devicePreference>30001</ns2:devicePreference>
                        <ns2:headline>HEADLINE</ns2:headline>
                        <ns2:description1>DESCRIPTION1</ns2:description1>
                        <ns2:description2>DESCRIPTION2</ns2:description2>
                    </ad>
                    <status>ENABLED</status>
                </operand>
            </operations>
        </mutate>
    </soapenv:Body>
</soapenv:Envelope>


Regards,
Shwetha, AdWords API Team.

srohde

unread,
Jun 27, 2016, 1:01:11 PM6/27/16
to AdWords API Forum
Thank you for your quick response. Unfortunately, I'm still unable to create a text ad with SOAP UI.  

Here's my request, updated to include your suggestions :

  1. <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v20="https://adwords.google.com/api/adwords/cm/v201605" xmlns:xsi="xsi">
  1.    <soapenv:Header>
  2.       <v20:RequestHeader>
  3.          <v20:clientCustomerId>[redacted]</v20:clientCustomerId>
  4.          <v20:developerToken>[redacted]</v20:developerToken>
  5.          <v20:validateOnly>false</v20:validateOnly>
  6.          <v20:partialFailure>false</v20:partialFailure>
  7.       </v20:RequestHeader>
  8.    </soapenv:Header>
  1.    <soapenv:Body>
  2.       <mutate xmlns="https://adwords.google.com/api/adwords/cm/v201605">
  3.          <operations>
  4.             <operator>ADD</operator>
  5.             <operand>
  1.                <adGroupId>[redacted]</adGroupId>
  1.                <ad xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201605" xsi:type="ns2:TextAd">
  1.                   <ns2:displayUrl>example.com</ns2:displayUrl>
  2.                   <ns2:finalUrls>http://www.example.com</ns2:finalUrls>
  1.                   <ns2:devicePreference>30001</ns2:devicePreference>
  1.                   <ns2:headline>Summer things</ns2:headline>
  2.                   <ns2:description1>Get things for summer</ns2:description1>
  3.                   <ns2:description2>while the prices are low.</ns2:description2>
  1.                </ad>
  2.                <status>ENABLED</status>
  3.             </operand>
  4.          </operations>
  5.       </mutate>
  6.    </soapenv:Body>
  7. </soapenv:Envelope>

    Here are validation errors in the request...

    line 16: Attribute not allowed (no wildcards allowed): type@xsi in element ad@https://adwords.google.com/api/adwords/cm/v201605
     
     
     
     

    And here is the API response to my updated request:

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
       <soap:Body>
          <soap:Fault>
             <faultcode>soap:Client</faultcode>
             <faultstring>Unmarshalling Error: cvc-complex-type.3.2.2: Attribute 'xsi:type' is not allowed to appear in element 'ad'.</faultstring>
          </soap:Fault>
       </soap:Body>
    </soap:Envelope>



    Can you pelase help me understand the defects in my request?

    Thanks!
     

    Shwetha Vastrad (AdWords API Team)

    unread,
    Jun 27, 2016, 5:55:31 PM6/27/16
    to AdWords API Forum
    Hi,

    The error you are getting could be because of incorrect namespace specifications. Could you try the request provided below and let me know if you are able to create TextAds successfully?

        <soapenv:Header>
            <ns1:RequestHeader xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201605" soapenv:mustUnderstand="0">
                <ns1:clientCustomerId>YOUR_CLIENT_CUSTOMER_ID</ns1:clientCustomerId>
                <ns1:developerToken>YOUR_DEVELOPER_TOKEN</ns1:developerToken>
                <ns1:userAgent>YOUR_USER_AGENT</ns1:userAgent>
                <ns1:validateOnly>false</ns1:validateOnly>
                <ns1:partialFailure>false</ns1:partialFailure>
            </ns1:RequestHeader>
        </soapenv:Header>
        <soapenv:Body>
                <operations>
                    <operator>ADD</operator>
                    <operand>
                        <adGroupId>AdGroupID</adGroupId>
                        <ad xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201605" xsi:type="ns2:TextAd">
                            <ns2:displayUrl>YOUR_DISPLAY_URL</ns2:displayUrl>
                            <ns2:finalUrls>YOUR_FINAL_URL</ns2:finalUrls>
                            <ns2:devicePreference>30001</ns2:devicePreference>
                            <ns2:headline>HEADLINE</ns2:headline>
                            <ns2:description1>DESCRIPTION1</ns2:description1>
                            <ns2:description2>DESCRIPTION2</ns2:description2>
                        </ad>
                        <status>PAUSED</status>
                    </operand>
                </operations>
            </mutate>
        </soapenv:Body>
    </soapenv:Envelope>
    Message has been deleted
    Message has been deleted

    srohde

    unread,
    Jun 27, 2016, 6:45:31 PM6/27/16
    to AdWords API Forum

    You example helped!  I was finally able to create a text ad using the following request:


       <soapenv:Header>
          <ns1:RequestHeader xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201605" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">
             <ns1:clientCustomerId>[redacted]</ns1:clientCustomerId>
             <ns1:developerToken>[redacted]</ns1:developerToken>
             <ns1:validateOnly>false</ns1:validateOnly>
             <ns1:partialFailure>false</ns1:partialFailure>
          </ns1:RequestHeader>
       </soapenv:Header>
       <soapenv:Body>
             <operations>
                <operator>ADD</operator>
                <operand>
                   <adGroupId>[redacted]</adGroupId>
                   <ad xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201605" xsi:type="ns2:TextAd">
                      <ns2:displayUrl>example.com</ns2:displayUrl>
                      <ns2:finalUrls>http://www.example.com</ns2:finalUrls>
                      <ns2:devicePreference>30001</ns2:devicePreference>
                      <ns2:headline>Summer things</ns2:headline>
                      <ns2:description1>Get things for summer</ns2:description1>
                      <ns2:description2>while the prices are low.</ns2:description2>
                   </ad>
                   <status>ENABLED</status>
                </operand>
             </operations>
          </mutate>
       </soapenv:Body>
    </soapenv:Envelope>



    Thank you very much.


    -Steve
    Reply all
    Reply to author
    Forward
    0 new messages