Adding a BlockIP entry
See original GitHub issueKudos for a good library. I’m trying to create a block IP criterion for a campaign and it’s failing with the following error:
"Fault": { "faultcode": "soap:Client", "faultstring": "Unexpected wrapper element mutate found. Expected {https://adwords.google.com/api/adwords/cm/v201609}mutate." }
I’m following the PHP library as advised and as a matter of fact have a working implementation of the same functionality in PHP with the one difference - in PHP I’m instantiating a NegativeCampaignCriterion which I’m not able to do here since the lib is using a standard object notation. This is why this looks like an issue with the library itself.
These are the methods/entities used:
- https://developers.google.com/adwords/api/docs/reference/v201607/CampaignCriterionService#mutate
- https://developers.google.com/adwords/api/docs/reference/v201607/CampaignCriterionService.CampaignCriterionOperation
- https://developers.google.com/adwords/api/docs/reference/v201607/CampaignCriterionService.CampaignCriterion
- https://developers.google.com/adwords/api/docs/reference/v201607/CampaignCriterionService.IpBlock
Here’s my implementation:
blockIp(accountNumber,campaignId,ip) {
var _this = this;
return _this.configure().then(function onApiConfigured() {
// prepare
var user = _this.prepareUser(accountNumber);
var service = user.getService('CampaignCriterionService', _this.gapi.version);
// build
var criterion = {
campaignId: campaignId,
isNegative: true,
criterion: { ipAddress: ip }
};
var operation = { operator: 'ADD', operand: criterion };
// wrap the call in a promise
return new Promise(function executeBlockIp(resolve,reject) {
service.mutate([operation], function onBlockIpDone(err, result) {
if(err) {
reject({ message: 'Google API error', error: err });
}
else {
resolve(result);
}
});
});
});
}
Please note that _this.prepareUser(accountNumber);
is working in other functionality implementations so there are no hidden problems, just the fact I seem to be failing at implementing this operation.
Can you advise? Needless to say I will appreciate a quick reply and assistance.
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (3 by maintainers)
Top GitHub Comments
Yes, it is functional. There are a ton of examples inside the test folder: https://github.com/ChrisAlvares/node-adwords/blob/master/test/adwords/services
and the readme explains how to use it.
Where did you get the id (blockId) in you criterion?