IncomeRange

52 views
Skip to first unread message

SHREYA

unread,
Dec 28, 2017, 3:23:00 AM12/28/17
to AdWords API Forum
When I use Google Adwords to target IncomeRange, I got an error saying "criterion ID required", but there are no constant codes for IncomeRange. Could you please help me with it.

Thanks in advance.

Bharani Cherukuri (AdWords API Team)

unread,
Dec 28, 2017, 10:45:49 AM12/28/17
to AdWords API Forum
Hi Shreya, 

Could you enable logging and share with us the complete SOAP request and response logs, so I can take a look at the error you're receiving? Please use Reply privately to author option to provide the details. 

Regards,
Bharani, AdWords API Team

Shreya Dama

unread,
Jan 2, 2018, 11:47:59 PM1/2/18
to AdWords API Forum
My code :

from googleads import adwords

ADGROUP_ID = 'xxxxxxxxxxxxx'

def main(client, adgroup_id):
  adgroup_criterion_service = client.GetService(
      'AdGroupCriterionService', version='v201710') 

  income = {
      'xsi_type': 'NegativeAdGroupCriterion',
      'adGroupId': adgroup_id,
      'criterion': {
          'xsi_type': 'IncomeRange',
          'incomeRangeType':'INCOME_RANGE_70_80'
          #'id':i
      }}
  
  # Construct operations and add ad group criteria.
  operations = [
      {
          'operator': 'ADD',
          'operand': income
      }
  ]
  ad_group_criteria = adgroup_criterion_service.mutate(
      operations)['value']

  for response in ad_group_criteria['value']:
      print ('campaign criterion with campaign ID %s and ID "%s" '
             'type "%s" was added.' %
             (response['campaignId'],
              response['criterion']['id'],
              response['criterion']['incomeRangeType']))

if __name__ == '__main__':
  adwords_client = adwords.AdWordsClient.LoadFromStorage()

  main(adwords_client, ADGROUP_ID)

The response i Get is:

Response summary - {'operations': 1, 'serviceName': AdGroupCriterionService, 'faultMessage': '[RequiredError.REQUIRED @ operations[0].operand.criterion.id]', 'responseTime': 236, 'requestId': 000561d7e03503f80a622745910dd0b1, 'methodName': mutate, 'isFault': True}

Traceback (most recent call last):


File "<ipython-input-1-2565dba4436a>", line 1, in <module>

runfile('/xxxxxxx/income range.py', wdir='/xxxxxxx')


File "/xxxxxxx/lib/python3.5/site-packages/spyder/utils/site/sitecustomize.py", line 866, in runfile

execfile(filename, namespace)


File "/xxxxxxx/lib/python3.5/site-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile

exec(compile(f.read(), filename, 'exec'), namespace)


File "/xxxxxxx/income range.py", line 45, in <module>

main(adwords_client, ADGROUP_ID)


File "/xxxxxxx/income range.py", line 33, in main

operations)['value']


File "/xxxxxxx/.local/lib/python3.5/site-packages/googleads/common.py", line 767, in MakeSoapRequest

self._packer) for arg in args])


File "/xxxxxxx/.local/lib/python3.5/site-packages/suds/client.py", line 521, in __call__

return client.invoke(args, kwargs)


File "/xxxxxxx/.local/lib/python3.5/site-packages/suds/client.py", line 581, in invoke

result = self.send(soapenv)


File "/xxxxxxx/.local/lib/python3.5/site-packages/suds/client.py", line 619, in send

description=tostr(e), original_soapenv=original_soapenv)


File "/xxxxxxx/.local/lib/python3.5/site-packages/suds/client.py", line 670, in process_reply

raise WebFault(fault, replyroot)


WebFault: Server raised fault: '[RequiredError.REQUIRED @ operations[0].operand.criterion.id]'


Anash P. Oommen (AdWords API Team)

unread,
Jan 5, 2018, 3:37:08 PM1/5/18
to AdWords API Forum
Hi Shreya,

The requested IDs are now published at https://developers.google.com/adwords/api/docs/appendix/codes-formats#income-ranges. Let me know if that works for you.

Cheers
Anash P. Oommen,
AdWords API Advisor.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages