ChrisAlvares / node-adwords

Adwords SDK for NodeJS
MIT License
151 stars 92 forks source link

Cannot Pause Keyword using AdGroupCriterionService #94

Open arthurkhlghatyan opened 5 years ago

arthurkhlghatyan commented 5 years ago

Hi,

I'm trying to pause AdWords account keyword using AdGroupCriterionService. Below is the configuration object for the mutate operation.

const operation = { operator: 'SET', operand: { adGroupId: '70223898612', criterion: { id: '301140923707', userStatus: 'PAUSED', matchType: 'EXACT', 'xsi:type': 'Keyword', }, }, };

I'm getting an error saying. body: 'soap:ClientUnmarshalling Error: cvc-complex-type.2.4.a: Invalid content was found starting with element \'{"https://adwords.google.com/api/adwords/cm/v201809":userStatus}\'. One of \'{"https://adwords.google.com/api/adwords/cm/v201809":type, "https://adwords.google.com/api/adwords/cm/v201809":Criterion.Type, "https://adwords.google.com/api/adwords/cm/v201809":text, "https://adwords.google.com/api/adwords/cm/v201809":matchType}\' is expected. </soap:Fault></soap:Body></soap:Envelope>' }

Just can't figure out what's the problem haha, please let me know if you have any thoughts about the issue.

Thanks.

encodeslife commented 5 years ago

Hello @arthurkhlghatyan , you've probably already figured out how you can update your keyword but here is an example from my code:

var user = new AdwordsUser({ ... });
const adGroupCriterionService = user.getService('AdGroupCriterionService', 'v201809');
const adGroupCriterionOperation = {
    operations: {
        operator: 'SET',
        operand: {
            adGroupId: yourAdGroupId,
            criterionUse: 'BIDDABLE',
            criterion: {
                id: yourKeywordId,
                type: 'KEYWORD',
                'xsi:type': 'Keyword'
            },
            userStatus: 'PAUSED',
            'xsi:type': 'BiddableAdGroupCriterion'
        }
    }
};

adGroupCriterionService.mutate(adGroupCriterionOperation, function (err, data) {
    if (err) {
        // ..
    } else {
        // ..
    }
});