Дайте пример XML запроса для сервиса AdGroupAdService использующий TextAd

188 views
Skip to first unread message

treto...@gmail.com

unread,
Jan 14, 2015, 11:31:24 AM1/14/15
to adwor...@googlegroups.com
Доброго времени суток!

Делаю запрос к сервису AdGroupAdService. 
Пример тела запроса:
  <?xml version=""1.0"" encoding=""UTF-8""?>
  <soapenv:Header>
 <v20:RequestHeader>
     <v20:clientCustomerId>ХХХХХХХХХХХХХХХХХХХ</v20:clientCustomerId>
     <v20:developerToken>ХХХХХХХХХХХХХХХХХХХХХ</v20:developerToken>
     <v20:userAgent>userAgent</v20:userAgent>
     <v20:validateOnly>false</v20:validateOnly>
     <v20:partialFailure>false</v20:partialFailure>
  </v20:RequestHeader>
  </soapenv:Header>
  <soapenv:Body>
     <v20:mutate>
        <v20:operations xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"">
           <v20:operator>"+СтруктураПараметров.Operator+"</v20:operator>
           <v20:operand>
              <v20:adGroupId>"+СтруктураПараметров.adGroupId+"</v20:adGroupId>
              <v20:ad>   
                 <v20:url>"+СтруктураПараметров.url+"</v20:url>
                 <v20:displayUrl>"+СтруктураПараметров.displayUrl+"</v20:displayUrl>
                 <v20:headline>"+СтруктураПараметров.headline+"</v20:headline>
                 <v20:description1>"+СтруктураПараметров.description1+"</v20:description1>
                 <v20:description2>"+СтруктураПараметров.description2+"</v20:description2>
              </v20:ad>
              <v20:status>ENABLED</v20:status>
              <v20:approvalStatus>APPROVED</v20:approvalStatus>
              <v20:labels>
                 <v20:name>"Текст"</v20:name>
              </v20:labels>
           </v20:operand>
        </v20:operations>
     </v20:mutate>
  </soapenv:Body>
</soapenv:Envelope>

в ответ получаю:
"Unmarshalling Error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'v20:headline'. One of '{"https://adwords.google.com/api/adwords/cm/v201409":finalUrls, "https://adwords.google.com/api/adwords/cm/v201409":finalMobileUrls, "https://adwords.google.com/api/adwords/cm/v201409":finalAppUrls, "https://adwords.google.com/api/adwords/cm/v201409":trackingUrlTemplate, "https://adwords.google.com/api/adwords/cm/v201409":urlCustomParameters, "https://adwords.google.com/api/adwords/cm/v201409":devicePreference, "https://adwords.google.com/api/adwords/cm/v201409":Ad.Type}' is expected. "

Может кто-то сталкивался? Как правильно сформировать запрос?

Josh Radcliff (AdWords API Team)

unread,
Jan 14, 2015, 1:45:27 PM1/14/15
to adwor...@googlegroups.com
Hi,

I strongly recommend using one of our client libraries instead of manually constructing your SOAP messages. Each client library lets you work with objects instead of XML elements, which makes building your requests far easier.

Thanks,
Josh, AdWords API Team

treto...@gmail.com

unread,
Jan 14, 2015, 1:51:59 PM1/14/15
to adwor...@googlegroups.com
Hi,
Thank you, but I can not use the client libraries for my programming language they simply do not
Could you give an example xml, using TekstAd?

среда, 14 января 2015 г., 20:45:27 UTC+2 пользователь Josh Radcliff (AdWords API Team) написал:

Josh Radcliff (AdWords API Team)

unread,
Jan 14, 2015, 5:41:25 PM1/14/15
to adwor...@googlegroups.com
Hi,

OK - here's an example that should help you get started:

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/
    <soapenv:Header>
        <ns1:RequestHeader xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201409" soapenv:mustUnderstand="0">
            <ns1:clientCustomerId>xxx</ns1:clientCustomerId>
            <ns1:developerToken>xxx</ns1:developerToken>
            <ns1:userAgent>xxx</ns1:userAgent>
            <ns1:validateOnly>false</ns1:validateOnly>
            <ns1:partialFailure>false</ns1:partialFailure>
        </ns1:RequestHeader>
    </soapenv:Header>
    <soapenv:Body>
            <operations>
                <operator>ADD</operator>
                <operand>
                    <adGroupId>XXXX</adGroupId>
                    <ad xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201409" xsi:type="ns2:TextAd">
                        <url>http://www.example.com</url>
                        <displayUrl>www.example.com</displayUrl>
                        <headline>Luxury Cruise to Mars</headline>
                        <description1>Visit the Red Planet in style.</description1>
                        <description2>Low-gravity fun for everyone!</description2>
                    </ad>
                    <status>PAUSED</status>
                </operand>
            </operations>
        </mutate>
    </soapenv:Body>
</soapenv:Envelope>

Cheers,
Josh, AdWords API Team

treto...@gmail.com

unread,
Jan 15, 2015, 2:37:04 AM1/15/15
to adwor...@googlegroups.com
Hi,
Thank you, took your example:

<ad xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201409xsi:type="ns2:TextAd">
    <url>http://www.example.com</url>
    <displayUrl>www.example.com</displayUrl>
    <headline>Luxury Cruise to Mars</headline>
    <description1>Visit the Red Planet in style.</description1>
    <description2>Low-gravity fun for everyone!</description2>
</ad>

when sending a query, I get an error on the line:

<ad xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201409" xsi:type="ns2:TextAd">

error:

Unmarshalling Error: ParseError at [row,col]:[18,108]


четверг, 15 января 2015 г., 0:41:25 UTC+2 пользователь Josh Radcliff (AdWords API Team) написал:
Message has been deleted

treto...@gmail.com

unread,
Jan 15, 2015, 4:05:24 AM1/15/15
to adwor...@googlegroups.com
My request:

<?xml version="1.0" encoding="UTF-8"?>
   <soapenv:Header>
  <v20:RequestHeader>
      <v20:clientCustomerId>xxx-xxx-xxxx</v20:clientCustomerId>
      <v20:developerToken>xxxxxxxxxxxxxxxxxxxxxx</v20:developerToken>
      <v20:userAgent>xxxxxxxx</v20:userAgent>
      <v20:validateOnly>false</v20:validateOnly>
      <v20:partialFailure>false</v20:partialFailure>
   </v20:RequestHeader>
   </soapenv:Header>
   <soapenv:Body>
      <v20:mutate>
         <v20:operations xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <v20:operator>ADD</v20:operator>
            <v20:operand>
               <v20:adGroupId>15754156713</v20:adGroupId>
               <v20:ad xsi:type="v20:TextAd">   
                  <v20:url>http://www.treto.ru</v20:url>
                  <v20:displayUrl>treto.ru</v20:displayUrl>
                  <v20:headline>Тестовое объявление treto.ru</v20:headline>
                  <v20:description1>description1: Тестовое объявление treto.ru</v20:description1>
                  <v20:description2>description2: Тестовое объявление treto.ru</v20:description2>
               </v20:ad>
               <v20:status>ENABLED</v20:status>
               <v20:approvalStatus>APPROVED</v20:approvalStatus>
               <v20:labels>
                  <v20:name>Тестовое объявление treto.ru</v20:name>
               </v20:labels>
            </v20:operand>
         </v20:operations>
      </v20:mutate>
   </soapenv:Body>
</soapenv:Envelope>

ERROR:

Unmarshalling Error: ParseError at [row,col]:[18,46]

четверг, 15 января 2015 г., 0:41:25 UTC+2 пользователь Josh Radcliff (AdWords API Team) написал:

treto...@gmail.com

unread,
Jan 15, 2015, 4:14:37 AM1/15/15
to adwor...@googlegroups.com
tried to make:

<v20:ad xsi:type=""TextAd"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">

ERROR:

Unmarshalling Error: cvc-elt.4.2: Cannot resolve 'TextAd' to a type definition for element 'v20:ad'. 


четверг, 15 января 2015 г., 11:05:24 UTC+2 пользователь treto...@gmail.com написал:

treto...@gmail.com

unread,
Jan 15, 2015, 4:32:28 AM1/15/15
to adwor...@googlegroups.com
If I tried to make:

<ad xmlns:ns2=""https://adwords.google.com/api/adwords/cm/v201409"" xsi:type=""ns2:TextAd"">

ERROR:

Message: http://www.w3.org/TR/1999/REC-xml-names-19990114#AttributePrefixUnbound?ad&xsi:type&xsi 

четверг, 15 января 2015 г., 11:14:37 UTC+2 пользователь treto...@gmail.com написал:

treto...@gmail.com

unread,
Jan 15, 2015, 4:52:49 AM1/15/15
to adwor...@googlegroups.com
I have worked like this:

<soapenv:Body>
         <v20:operations xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <v20:operator>ADD</v20:operator>
            <v20:operand>
               <v20:adGroupId>15889158713</v20:adGroupId>
                <ad xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201409" i:type="ns2:TextAd">
                  <v20:url>http://www.ex.ru</v20:url>
                  <v20:displayUrl>ex.ru</v20:displayUrl>
                  <v20:headline>Тестовое объявление </v20:headline>
                  <v20:description1>Тестовое объявление 1</v20:description1>
                  <v20:description2>Тестовое объявление  2</v20:description2>
               </ad>
               <v20:status>ENABLED</v20:status>
               <v20:approvalStatus>APPROVED</v20:approvalStatus>
            </v20:operand>
         </v20:operations>
      </v20:mutate>
   </soapenv:Body>

четверг, 15 января 2015 г., 11:32:28 UTC+2 пользователь treto...@gmail.com написал:

Josh Radcliff (AdWords API Team)

unread,
Jan 15, 2015, 9:50:29 AM1/15/15
to adwor...@googlegroups.com
Hi,

From your last response, it sounds like you have got this working now. If that's not the case, could you post the errors you are now encountering?

Thanks,
Josh, AdWords API Team
Reply all
Reply to author
Forward
0 new messages