Hi, 

I'm trying to update my max cpc bid for a specific product in adwords.
Via the webui of adwords this is a trivial task, however doing it via the 
api results in an error. 

Screenshot and code are attached.

Executing this gives a 'Unmarshalling Error: cvc-elt.4.2: Cannot resolve 
'ns2:ProductScope' to a type definition for element 'ns2:criterion''.

https://groups.google.com/forum/#!msg/adwords-api/qqN18iy06L0/XG1DZ1S0B0IJ 
gives some hints.
I'm unsure how to incorporate the 'ProductPartition with the 
ProductDimension on the caseValue of the ProductOfferId' in my code.

A working example of how to perform this task would really help me out :)

Kind regards,
Barrie

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/7f2456b9-b83e-4719-b51d-3db26fe82514%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
package nl.cherrymountains.bidding.fct.google;

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;

/**
 * @author bkersbergen
 */
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);


        /**
         Exception in thread "main" AxisFault
         faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
         faultSubcode:
         faultString: Unmarshalling Error: cvc-elt.4.2: Cannot resolve 'ns2:ProductScope' to a type definition for element 'ns2:criterion'.
         faultActor:
         faultNode:
         faultDetail:
         {http://xml.apache.org/axis/}stackTrace:Unmarshalling Error: cvc-elt.4.2: Cannot resolve 'ns2:ProductScope' to a type definition for element 'ns2:criterion'.
         at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
         at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
         at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2967)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
         at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)
         at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
         at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
         at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
         at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
         at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
         at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
         at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
         at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
         at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
         at org.apache.axis.client.Call.invoke(Call.java:2767)
         at org.apache.axis.client.Call.invoke(Call.java:2443)
         at org.apache.axis.client.Call.invoke(Call.java:2366)
         at org.apache.axis.client.Call.invoke(Call.java:1812)
         at com.google.api.ads.adwords.axis.v201607.cm.AdGroupCriterionServiceSoapBindingStub.mutate(AdGroupCriterionServiceSoapBindingStub.java:1772)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke(Method.java:498)
         at com.google.api.ads.common.lib.soap.SoapClientHandler.invoke(SoapClientHandler.java:109)
         at com.google.api.ads.common.lib.soap.axis.AxisHandler.invokeSoapCall(AxisHandler.java:248)
         at com.google.api.ads.common.lib.soap.SoapServiceClient.callSoapClient(SoapServiceClient.java:62)
         at com.google.api.ads.common.lib.soap.SoapServiceClient.invoke(SoapServiceClient.java:92)
         at com.sun.proxy.$Proxy18.mutate(Unknown Source)
         at nl.cherrymountains.bidding.fct.google.ChangeBidOnSpecificProduct.changeBidViaApi(ChangeBidOnSpecificProduct.java:63)
         at nl.cherrymountains.bidding.fct.google.ChangeBidOnSpecificProduct.main(ChangeBidOnSpecificProduct.java:35)

         Process finished with exit code 1
         */
    }
}

Reply via email to