ruby adwords client v17.0.1

20 views
Skip to first unread message

mariek

unread,
Nov 20, 2009, 8:25:04 AM11/20/09
to AdWords API Forum
I am trying to update keyword text and its destinationUrl.

1. I specify it in the way showed below, and it updates correctly
destinationUrl but text for keyword stay the same. In response there
is also old text
2. It is also strange that if I specify adGroupId, keyword.id and
don't specify keyword.text and keyword.matchType it will not perform
update. Result is error that text and type is required.

kwd_operation =
ad_group_criterion_srv.module::AdGroupCriterionOperation.new
kwd_operand =
ad_group_criterion_srv.module::BiddableAdGroupCriterion.new
kwd_operand.adGroupId = ADGROUPID
keyword = ad_group_criterion_srv.module::Keyword.new
keyword.matchType = 'BROAD'
keyword.id = KEYWORDID
keyword.text = 'text to update'
kwd_operand.destinationUrl = URL
kwd_operand.criterion = keyword
kwd_operation.operand = kwd_operand
kwd_operation.operator = 'SET'
kwd_operation.exemptionRequests = []

POINT 1 request and response

! CONNECT TO adwords.google.com:443

! CONNECTION ESTABLISHED

POST /api/adwords/cm/v200909/AdGroupCriterionService HTTP/1.1
SOAPAction: ""
Content-Type: text/xml; charset=utf-8
User-Agent: SOAP4R/1.5.8 (httpclient.rb/280, ruby 1.8.7 (2008-08-11)
[i486-linux])
Date: Fri, 20 Nov 2009 12:41:18 GMT
Content-Length: 1596
Host: adwords.google.com

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<n1:RequestHeader env:mustUnderstand="0"
xmlns:n1="https://adwords.google.com/api/adwords/cm/
v200909">
<n1:authToken>xxx</n1:authToken>
<n1:userAgent>adwords4r: xxxx</n1:userAgent>
<n1:applicationToken>xxx</n1:applicationToken>
<n1:developerToken>xxx</n1:developerToken>
<n1:clientEmail>xxxx</n1:clientEmail>
</n1:RequestHeader>
</env:Header>
<env:Body>
<n2:mutate xmlns:n2="https://adwords.google.com/api/adwords/cm/
v200909">
<n2:operations xsi:type="n2:AdGroupCriterionOperation">
<n2:operator>SET</n2:operator>
<n2:operand xsi:type="n2:BiddableAdGroupCriterion">
<n2:adGroupId>ADGROUPID</n2:adGroupId>
<n2:criterion xsi:type="n2:Keyword">
<n2:id>KEYWORDID</n2:id>
<n2:text>text to update</n2:text>
<n2:matchType>BROAD</n2:matchType>
</n2:criterion>
<n2:destinationUrl>URL</n2:destinationUrl>
</n2:operand>
</n2:operations>
</n2:mutate>
</env:Body>
</env:Envelope>

= Response

HTTP/1.1 200 OK

Content-Type: text/xml; charset=UTF-8

SOAPAction: ""

Transfer-Encoding: chunked

Date: Fri, 20 Nov 2009 12:41:17 GMT

Expires: Fri, 20 Nov 2009 12:41:17 GMT

Cache-Control: private, max-age=0

X-Content-Type-Options: nosniff

X-XSS-Protection: 0

X-Frame-Options: SAMEORIGIN

Server: GFE/2.0

614

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/
envelope/"><soap:Header><ResponseHeader xmlns="https://
adwords.google.com/api/adwords/cm/
v200909"><requestId>3da83ffe3f6331f2cc3b37e4031c1a18</
requestId><operations>1</operations><responseTime>470</
responseTime><units>3</units></ResponseHeader></
soap:Header><soap:Body><mutateResponse xmlns="https://
adwords.google.com/api/adwords/cm/
v200909"><rval><ListReturnValue.Type>AdGroupCriterionReturnValue</
ListReturnValue.Type><value xmlns:xsi="http://www.w3.org/2001/
XMLSchema-instance"
xsi:type="BiddableAdGroupCriterion"><adGroupId>820969566</
adGroupId><criterion xsi:type="Keyword"><id>376765347</
id><Criterion.Type>Keyword</Criterion.Type><text>TEXT</
text><matchType>BROAD</matchType></
criterion><AdGroupCriterion.Type>BiddableAdGroupCriterion</
AdGroupCriterion.Type><userStatus>ACTIVE</
userStatus><systemServingStatus>ELIGIBLE</
systemServingStatus><approvalStatus>PENDING_REVIEW</
approvalStatus><destinationUrl>URL</
destinationUrl><bids
xsi:type="ManualCPCAdGroupCriterionBids"><AdGroupCriterionBids.Type>ManualCPCAdGroupCriterionBids</
AdGroupCriterionBids.Type><maxCpc><amount><ComparableValue.Type>Money</
ComparableValue.Type><microAmount>610000</microAmount></amount></
maxCpc><bidSource>ADGROUP</bidSource></
bids><firstPageCpc><amount><ComparableValue.Type>Money</
ComparableValue.Type><microAmount>60000</microAmount></amount></
firstPageCpc><qualityInfo><qualityScore>7</qualityScore></
qualityInfo></value></rval></mutateResponse></soap:Body></
soap:Envelope>

0

! CONNECTION CLOSED

POINT 2 request and response

= Request

! CONNECT TO adwords.google.com:443

! CONNECTION ESTABLISHED

POST /api/adwords/cm/v200909/AdGroupCriterionService HTTP/1.1
SOAPAction: ""
Content-Type: text/xml; charset=utf-8
User-Agent: SOAP4R/1.5.8 (httpclient.rb/280, ruby 1.8.7 (2008-08-11)
[i486-linux])
Date: Fri, 20 Nov 2009 12:25:24 GMT
Content-Length: 1482
Host: adwords.google.com

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<n1:RequestHeader env:mustUnderstand="0"
xmlns:n1="https://adwords.google.com/api/adwords/cm/
v200909">
<n1:authToken>xxxx</n1:authToken>
<n1:userAgent>xxx</n1:userAgent>
<n1:applicationToken>xxx</n1:applicationToken>
<n1:developerToken>xxxx</n1:developerToken>
<n1:clientEmail>xxxx</n1:clientEmail>
</n1:RequestHeader>
</env:Header>
<env:Body>
<n2:mutate xmlns:n2="https://adwords.google.com/api/adwords/cm/
v200909">
<n2:operations xsi:type="n2:AdGroupCriterionOperation">
<n2:operator>SET</n2:operator>
<n2:operand xsi:type="n2:BiddableAdGroupCriterion">
<n2:adGroupId>ADGROUPID</n2:adGroupId>
<n2:criterion xsi:type="n2:Keyword">
<n2:id>KEYWORDID</n2:id>
</n2:criterion>
<n2:destinationUrl>URL WHICH I WANT TO SET</
n2:destinationUrl>
</n2:operand>
</n2:operations>
</n2:mutate>
</env:Body>
</env:Envelope>

= Response

HTTP/1.1 200 OK

Content-Type: text/xml; charset=UTF-8

Transfer-Encoding: chunked

Date: Fri, 20 Nov 2009 12:25:23 GMT

Expires: Fri, 20 Nov 2009 12:25:23 GMT

Cache-Control: private, max-age=0

X-Content-Type-Options: nosniff

X-XSS-Protection: 0

X-Frame-Options: SAMEORIGIN

Server: GFE/2.0

573

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/
envelope/"><soap:Header><ResponseHeader xmlns="https://
adwords.google.com/api/adwords/cm/
v200909"><requestId>ecbfbbc4ddab908ec17214f978b9eb1c</
requestId><operations>1</operations><responseTime>347</
responseTime><units>3</units></ResponseHeader></
soap:Header><soap:Body><soap:Fault><faultcode>soap:Server</
faultcode><faultstring>[RequiredError.REQUIRED @ operations
[0].operand.criterion.text, RequiredError.REQUIRED @ operations
[0].operand.criterion.matchType]</
faultstring><detail><ApiExceptionFault xmlns="https://
adwords.google.com/api/adwords/cm/v200909"><message>
[RequiredError.REQUIRED @ operations[0].operand.criterion.text,
RequiredError.REQUIRED @ operations[0].operand.criterion.matchType]</
message><ApplicationException.Type>ApiException</
ApplicationException.Type><errors xmlns:xsi="http://www.w3.org/2001/
XMLSchema-instance" xsi:type="RequiredError"><fieldPath>operations
[0].operand.criterion.text</fieldPath><trigger></
trigger><ApiError.Type>RequiredError</ApiError.Type><reason>REQUIRED</
reason></errors><errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xsi:type="RequiredError"><fieldPath>operations
[0].operand.criterion.matchType</fieldPath><trigger></
trigger><ApiError.Type>RequiredError</ApiError.Type><reason>REQUIRED</
reason></errors></ApiExceptionFault></detail></soap:Fault></
soap:Body></soap:Envelope>

0

! CONNECTION CLOSED

AdWords API Advisor

unread,
Nov 20, 2009, 9:54:23 AM11/20/09
to AdWords API Forum
Hi,

It's possible to update an AdGroupCriterion without specifying the
keyword text and match type, but you need to ensure the criterion
field is types as Criterion and not Keyword. For example, this
section of the XML:

<n2:criterion xsi:type="n2:Keyword">
<n2:id>KEYWORDID</n2:id>
</n2:criterion>

should look like:

<n2:criterion>
<n2:id>KEYWORDID</n2:id>
</n2:criterion>

and your code should look like:

keyword = ad_group_criterion_srv.module::Criterion.new
keyword.id = KEYWORDID

Best,
- Eric Koleda, AdWords API Team
> xsi:type="ManualCPCAdGroupCriterionBids"><AdGroupCriterionBids.Type>ManualC PCAdGroupCriterionBids</

rkal

unread,
Dec 3, 2009, 9:17:04 AM12/3/09
to AdWords API Forum
Hi Eric,

Comming back to this, in terms of updating keyword match type and
keyword text - the way you suggested do not work.
The request object is generated properly:

<AdWords::V200909::AdGroupCriterionService::AdGroupCriterionOperation:
0x7f8d81ec78c0
@exemptionRequests=[],
@operand=

#<AdWords::V200909::AdGroupCriterionService::BiddableAdGroupCriterion:
0x7f8d81ec7820
@adGroupCriterion_Type=nil,
@adGroupId=xxxxxx
@approvalStatus=nil,
@bids=nil,
@criterion=
#<AdWords::V200909::AdGroupCriterionService::Keyword:
0x7f8d81ec77d0
@criterion_Type=nil,
@id=xxxxxx
@matchType="PHRASE",
@text="test 2">,
@destinationUrl=nil,
@firstPageCpc=nil,
@qualityInfo=nil,
@stats=nil,
@systemServingStatus=nil,
@userStatus=nil>,
@operation_Type=nil,
@operator="SET">

As a result neither text, nor match type is changed.
Any ideas with it?

Thanks in advance
Rafal

AdWords API Advisor

unread,
Dec 3, 2009, 9:36:14 AM12/3/09
to AdWords API Forum
Hi Rafal,

The method I described can be used to update properties of the
AdGroupCriterion (in this case BiddableAdGroupCriterion), such as the
destination URL. However, the properties of the keyword itself, such
as text and matchType, cannot be update. If you want to change the
text and match type you should remove the old keyword and add a new
one.

Best,
- Eric
Reply all
Reply to author
Forward
0 new messages