Я хочу обновить ставку max cpc для определенного продукта в adwords. Через webui adwords это тривиальная задача, но я не могу заставить ее работать в коде, это то, что у меня есть до сих пор.обновить/установить maxcpc на одном конкретном продукте для покупок в группе объявлений
import com.google.api.ads.adwords.axis.factory.AdWordsServices;
import com.google.api.ads.adwords.axis.v201607.cm.*;
import com.google.api.ads.adwords.lib.client.AdWordsSession;
import com.google.api.ads.common.lib.auth.OfflineCredentials;
import com.google.api.client.auth.oauth2.Credential;
import java.rmi.RemoteException;
public class ChangeBidOnSpecificProduct {
public static void main(String[] args) throws Exception {
OfflineCredentials build = new OfflineCredentials.Builder()
.forApi(OfflineCredentials.Api.ADWORDS)
.fromFile()
.build();
Credential oAuth2Credential = build
.generateCredential();
// Construct an AdWordsSession.
AdWordsSession session = new AdWordsSession.Builder()
.fromFile()
.withOAuth2Credential(oAuth2Credential)
.build();
String accountId = "ACCOUNT_ID";
Long campaignId = Long.valueOf("CAMPAIGN_ID");
long adGroupId = Long.valueOf("ADGROUP_ID");
session.setClientCustomerId(accountId);
Money money = new Money(null, 40000L);
String productId = "9200000050670959";
changeBidViaApi(session, campaignId, adGroupId, productId, money);
}
private static void changeBidViaApi(AdWordsSession session, Long campaignId, long adGroupId, String productId, Money newValue) throws RemoteException {
ProductOfferId productOfferId = new ProductOfferId();
productOfferId.setValue(productId);
ProductScope productScope = new ProductScope();
productScope.setDimensions(new ProductDimension[] {productOfferId});
BiddableAdGroupCriterion biddableAdGroupCriterion = new BiddableAdGroupCriterion();
biddableAdGroupCriterion.setAdGroupId(adGroupId);
biddableAdGroupCriterion.setCriterion(productScope);
BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
CpcBid bid = new CpcBid();
bid.setBid(newValue);
biddingStrategyConfiguration.setBids(new Bids[]{bid});
biddableAdGroupCriterion.setBiddingStrategyConfiguration(biddingStrategyConfiguration);
AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
operation.setOperand(biddableAdGroupCriterion);
operation.setOperator(Operator.SET);
AdGroupCriterionOperation[] operations = new AdGroupCriterionOperation[]{operation};
AdWordsServices adWordsServices = new AdWordsServices();
AdGroupCriterionServiceInterface adGroupCriterionService =
adWordsServices.get(session, AdGroupCriterionServiceInterface.class);
AdGroupCriterionReturnValue result = adGroupCriterionService.mutate(operations);
}
}
Выполнение это приводит к ошибке: 'Ошибка немаршалинг: CVC-elt.4.2: Не удается разрешить 'NS2: ProductScope' для определения типа для элемента 'NS2: критерий''.
Это (anonimized) данные, которые отправить Google:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:RequestHeader soapenv:mustUnderstand="0" xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201607">
<ns1:clientCustomerId>ACCOUNT_ID</ns1:clientCustomerId>
<ns1:developerToken>MY_DEV_TOKEN</ns1:developerToken>
<ns1:userAgent>MY_UA</ns1:userAgent>
<ns1:validateOnly>false</ns1:validateOnly>
<ns1:partialFailure>false</ns1:partialFailure>
</ns1:RequestHeader>
</soapenv:Header>
<soapenv:Body>
<mutate xmlns="https://adwords.google.com/api/adwords/cm/v201607">
<operations>
<operator>SET</operator>
<operand xsi:type="ns2:BiddableAdGroupCriterion" xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201607">
<ns2:adGroupId>ADGROUP_ID</ns2:adGroupId>
<ns2:criterion xsi:type="ns2:ProductScope">
<ns2:dimensions xsi:type="ns2:ProductOfferId">
<ns2:value>9200000050670959</ns2:value>
</ns2:dimensions>
</ns2:criterion>
<ns2:biddingStrategyConfiguration>
<ns2:bids xsi:type="ns2:CpcBid">
<ns2:bid>
<ns2:microAmount>1</ns2:microAmount>
</ns2:bid>
</ns2:bids>
</ns2:biddingStrategyConfiguration>
</operand>
</operations>
</mutate>
</soapenv:Body>
</soapenv:Envelope>
Любые предложения в качестве причины ошибки или то, что я делаю неправильно здесь?