How does a Batched operation response work?

94 views
Skip to first unread message

Oliver

unread,
Jan 19, 2015, 11:23:17 AM1/19/15
to adwor...@googlegroups.com
Assume we want to create 10 new text Ads.

We use AdGroupAd.mutate() and pass the 10 AdGroupAdOperation objects. The response from the mutate method is an AdGroupAdReturnValue object.

Assume the creation of 3 out of the 10 Ads failed (Policy violation, etc.)

How long is the AdGroupAd[] array that is returned by AdGroupAdReturnValue,getValue()?

If it's 10, what is returned for the Ads that failed to be created?

If it's 7, how do we know which Ads these 7 are?


Thanks

Oliver

Anash P. Oommen (AdWords API Team)

unread,
Jan 19, 2015, 11:03:03 PM1/19/15
to adwor...@googlegroups.com
Hi Oliver,

The behavior is controlled by an AdWords API SOAP header called partialFailure. If you disable partialFailure, then the whole request fails if at least one operation fails (this is the default). If you enable partial failure, the failed operations will be returned in a separate field of the results, and you can look at the error fieldPath to figure out the index of the failed operation. See https://github.com/googleads/googleads-dotnet-lib/blob/master/examples/AdWords/CSharp/v201409/ErrorHandling/HandlePartialFailures.cs for an example.

Cheers,
Anash P. Oommen,
AdWords API Advisor.

Oliver

unread,
Jan 20, 2015, 3:33:52 AM1/20/15
to adwor...@googlegroups.com
Thanks Anash.

I forgot to mention we have partialFailure enabled.  We're also aware of how to find out about the failed operations as you pointed out in the examples.

Our question was about how to handle the successful operations returned result.  We need to know the ID of the new ads that were successfully created.  We get an AdGroupAd[] array from AdGroupAdReturnValue.getValue() which has this data.  However, we're not sure how the data is positioned there. 

In the example I gave, if the 3 failed Ads are not in that array, then how do we know which 7 Ads succeeded (since the array position will be different from the operation position).

However, if the array is 10 objects long, then what value do you provide for the failed Ads?


Oliver

Anash P. Oommen (AdWords API Team)

unread,
Jan 20, 2015, 6:39:57 AM1/20/15
to adwor...@googlegroups.com
Hi Oliver,

All the operations (failed and successful) will be returned in the results, in the same order as you passed them to the server. But the failed operations will not have a valid ad field or ids. You can use either that information, or lookup the errors to see which operations failed and why.

Cheers,
Anash P. Oommen,
AdWords API Advisor.

Oliver

unread,
Jan 20, 2015, 7:11:27 AM1/20/15
to adwor...@googlegroups.com
Thanks Anash.

Just to confirm, when you say:
>> But the failed operations will not have a valid ad field or ids.

Do you mean there will be a NULL in the position of the failed Ad, or do you mean there will be an AdGroupAd with invalid Ad ID (maybe something like 0)?

Anash P. Oommen (AdWords API Team)

unread,
Jan 22, 2015, 2:49:39 AM1/22/15
to adwor...@googlegroups.com
Hi Oliver,

Here's a log that shows you how a partialFailure request looks like. You can see that the second and 4th operations fail, so they have an empty AdGroupCriterion node (bolded). The partialFailures node tells what went wrong.

Cheers,
Anash

AdsClientLibs.DetailedRequestLogs Information: 1 :
-----------------BEGIN API CALL---------------------

Request
-------

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
<soap:Header>
   
<RequestHeader xmlns="https://adwords.google.com/api/adwords/cm/v201409">
     
<developerToken>******</developerToken>
     
<clientCustomerId>******</clientCustomerId>
     
<userAgent>INSERT_YOUR_COMPANY_OR_APPLICATION_NAME_HERE (AwApi-DotNet/18.7.0, Common-Dotnet/3.5.0, .NET CLR/4.0.30319.34209, gzip)</userAgent>
     
<partialFailure>true</partialFailure>
    </
RequestHeader>
 
</soap:Header>
  <soap:Body>
    <mutate xmlns="https:/
/adwords.google.com/api/adwords/cm/v201409">
      <operations>
        <operator>ADD</operator>
        <operand xsi:type="
BiddableAdGroupCriterion">
          <adGroupId>2035225096</adGroupId>
          <criterion xsi:type="
Keyword">
            <text>mars cruise</text>
            <matchType>BROAD</matchType>
          </criterion>
        </operand>
      </operations>
      <operations>
        <operator>ADD</operator>
        <operand xsi:type="
BiddableAdGroupCriterion">
          <adGroupId>2035225096</adGroupId>
          <criterion xsi:type="
Keyword">
            <text>inv@lid cruise</text>
            <matchType>BROAD</matchType>
          </criterion>
        </operand>
      </operations>
      <operations>
        <operator>ADD</operator>
        <operand xsi:type="
BiddableAdGroupCriterion">
          <adGroupId>2035225096</adGroupId>
          <criterion xsi:type="
Keyword">
            <text>venus cruise</text>
            <matchType>BROAD</matchType>
          </criterion>
        </operand>
      </operations>
      <operations>
        <operator>ADD</operator>
        <operand xsi:type="
BiddableAdGroupCriterion">
          <adGroupId>2035225096</adGroupId>
          <criterion xsi:type="
Keyword">
            <text>b(a)d keyword cruise</text>
            <matchType>BROAD</matchType>
          </criterion>
        </operand>
      </operations>
    </mutate>
  </soap:Body>
</soap:Envelope>


Response
--------

<?xml version="
1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/">
 
<soap:Header>
   
<ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201409">
     
<requestId>00050d38a2c41f480ab6426e570076f6</requestId>
      <serviceName>AdGroupCriterionService</
serviceName>
     
<methodName>mutate</methodName>
      <operations>0</
operations>
     
<responseTime>306</responseTime>
    </
ResponseHeader>
 
</soap:Header>
  <soap:Body>
    <mutateResponse xmlns="https:/
/adwords.google.com/api/adwords/cm/v201409">
      <rval>
        <ListReturnValue.Type>AdGroupCriterionReturnValue</ListReturnValue.Type>
        <value xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:type="BiddableAdGroupCriterion">
         
<adGroupId>2035225096</adGroupId>
          <criterion xsi:type="Keyword">
            <id>376765347</
id>
           
<type>KEYWORD</type>
            <Criterion.Type>Keyword</
Criterion.Type>
           
<text>mars cruise</text>
            <matchType>BROAD</
matchType>
         
</criterion>
          <AdGroupCriterion.Type>BiddableAdGroupCriterion</
AdGroupCriterion.Type>
         
<userStatus>ENABLED</userStatus>
          <systemServingStatus>ELIGIBLE</
systemServingStatus>
         
<approvalStatus>APPROVED</approvalStatus>
          <biddingStrategyConfiguration>
            <biddingStrategyType>MANUAL_CPC</
biddingStrategyType>
           
<biddingStrategySource>CAMPAIGN</biddingStrategySource>
            <biddingScheme xsi:type="ManualCpcBiddingScheme">
              <BiddingScheme.Type>ManualCpcBiddingScheme</
BiddingScheme.Type>
             
<enhancedCpcEnabled>true</enhancedCpcEnabled>
            </
biddingScheme>
           
<bids xsi:type="CpcBid">
             
<Bids.Type>CpcBid</Bids.Type>
              <bid>
                <ComparableValue.Type>Money</
ComparableValue.Type>
               
<microAmount>530000</microAmount>
              </
bid>
             
<cpcBidSource>ADGROUP</cpcBidSource>
            </
bids>
         
</biddingStrategyConfiguration>
        </
value>
        <value>
         
<AdGroupCriterion.Type>AdGroupCriterion</AdGroupCriterion.Type>
        </
value>

       
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="BiddableAdGroupCriterion">
         
<adGroupId>2035225096</adGroupId>
          <criterion xsi:type="Keyword">
            <id>400288707</
id>
           
<type>KEYWORD</type>
            <Criterion.Type>Keyword</
Criterion.Type>
           
<text>venus cruise</text>
            <matchType>BROAD</
matchType>
         
</criterion>
          <AdGroupCriterion.Type>BiddableAdGroupCriterion</
AdGroupCriterion.Type>
         
<userStatus>ENABLED</userStatus>
          <systemServingStatus>ELIGIBLE</
systemServingStatus>
         
<approvalStatus>APPROVED</approvalStatus>
          <biddingStrategyConfiguration>
            <biddingStrategyType>MANUAL_CPC</
biddingStrategyType>
           
<biddingStrategySource>CAMPAIGN</biddingStrategySource>
            <biddingScheme xsi:type="ManualCpcBiddingScheme">
              <BiddingScheme.Type>ManualCpcBiddingScheme</
BiddingScheme.Type>
             
<enhancedCpcEnabled>true</enhancedCpcEnabled>
            </
biddingScheme>
           
<bids xsi:type="CpcBid">
             
<Bids.Type>CpcBid</Bids.Type>
              <bid>
                <ComparableValue.Type>Money</
ComparableValue.Type>
               
<microAmount>530000</microAmount>
              </
bid>
             
<cpcBidSource>ADGROUP</cpcBidSource>
            </
bids>
         
</biddingStrategyConfiguration>
        </
value>
        <value>
         
<AdGroupCriterion.Type>AdGroupCriterion</AdGroupCriterion.Type>
        </
value>

       
<partialFailureErrors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CriterionError">
         
<fieldPath>operations[1].operand.criterion.text</fieldPath>
          <trigger>inv@lid cruise</
trigger>
         
<errorString>CriterionError.KEYWORD_HAS_INVALID_CHARS</errorString>
          <ApiError.Type>CriterionError</
ApiError.Type>
         
<reason>KEYWORD_HAS_INVALID_CHARS</reason>
        </
partialFailureErrors>
       
<partialFailureErrors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CriterionError">
         
<fieldPath>operations[3].operand.criterion.text</fieldPath>
          <trigger>b(a)d keyword cruise</
trigger>
         
<errorString>CriterionError.KEYWORD_HAS_INVALID_CHARS</errorString>
          <ApiError.Type>CriterionError</
ApiError.Type>
         
<reason>KEYWORD_HAS_INVALID_CHARS</reason>
        </
partialFailureErrors>
     
</rval>
    </
mutateResponse>
 
</soap:Body>
</
soap:Envelope>
-----------------END API CALL-----------------------

Reply all
Reply to author
Forward
0 new messages