使用 Google Adwords API 时出现解组错误
Posted
技术标签:
【中文标题】使用 Google Adwords API 时出现解组错误【英文标题】:Getting Unmarshalling Error while using Google Adwords API 【发布时间】:2013-10-16 13:48:25 【问题描述】:我正在使用 OAuth2 作为身份验证机制,以使用 SOAP 请求获取有关“添加预算活动”的响应。在开始使用 cUrl 发送一个肥皂请求时,我遇到了以下错误:
<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 'biddingStrategy'. One of '"https://adwords.google.com/api/adwords/cm/v201309":conversionOptimizerEligibility, "https://adwords.google.com/api/adwords/cm/v201309":adServingOptimizationStatus, "https://adwords.google.com/api/adwords/cm/v201309":frequencyCap, "https://adwords.google.com/api/adwords/cm/v201309":settings, "https://adwords.google.com/api/adwords/cm/v201309":networkSetting, "https://adwords.google.com/api/adwords/cm/v201309":biddingStrategyConfiguration, "https://adwords.google.com/api/adwords/cm/v201309":forwardCompatibilityMap' is expected.
</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
我正在使用 cUrl 发送以下 XML/SOAP 请求,这与 AdWords 教程 (https://developers.google.com/adwords/api/docs/guides/soap) 中给出的类似代码。
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns="https://adwords.google.com/api/adwords/cm/v201309">
<soap:Header>
<RequestHeader>
<authToken>MYAUTHTOKEN</authToken>
<userAgent>curl-tutorial</userAgent>
<developerToken>MYDEVTOKEN</developerToken>
<clientCustomerId>MYCUSTOMERID</clientCustomerId>
</RequestHeader>
</soap:Header>
<soap:Body>
<mutate>
<operations>
<operator>ADD</operator>
<operand>
<name>Test File</name>
<budget>
<period>DAILY</period>
<amount>
<microAmount>1000000000</microAmount>
</amount>
<deliveryMethod>STANDARD</deliveryMethod>
</budget>
<biddingStrategy
xmlns:cm="https://adwords.google.com/api/adwords/cm/v201309"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="cm:ManualCPC"/>
<settings
xmlns:cm="https://adwords.google.com/api/adwords/cm/v201309"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="cm:KeywordMatchSetting">
<cm:optIn>false</cm:optIn>
</settings>
</operand>
</operations>
</mutate>
</soap:Body>
</soap:Envelope>
我在 cUrl 请求中使用了上述 XML/SOAP 请求:
curl --header "Content-Type: application/soap+xml"
--data @test.xml https://adwords.google.com/api/adwords/cm/v201309/CampaignService
我在互联网上搜索了我面临的相同问题,但没有找到解决方案。如果我做错了什么,请告诉我,或者如果有其他出路,请告诉我。
【问题讨论】:
【参考方案1】:广告系列没有竞价策略。他们有竞价策略配置。看看参考:https://developers.google.com/adwords/api/docs/reference/v201309/CampaignService.Campaign
【讨论】:
以上是关于使用 Google Adwords API 时出现解组错误的主要内容,如果未能解决你的问题,请参考以下文章
Google Adwords API with OAuth2 如何获取授权用户的电子邮件?
google adwords api 与 google-adwords-api gem
与链接到 Google Adwords 帐户的 Google Analytics API 相比,Google Adwords API 报告可以获得多少?