Check if Label already exists.

68 views
Skip to first unread message

Shree

unread,
Jan 15, 2015, 2:05:55 AM1/15/15
to adwor...@googlegroups.com
I am trying to write a code in Python to check if Label 'MyLabel' already exists in my adwords account.
How to specify serviceSelector in LabelService.get ? How to make the code working ?
   
    label_service = client.GetService('LabelService', version='v201409')
    serviceSelector = {'fields': ['id', 'name'],
                  'predicates' : {'field' : 'name', 'operator' : 'EQUALS', 'values' : 'MyLabel'}
                }
    result =  label_service.get(serviceSelector)

Gives me error  for fields id and name : SelectorError.INVALID_FIELD_NAME @serviceSelector

Anash P. Oommen (AdWords API Team)

unread,
Jan 15, 2015, 4:06:02 AM1/15/15
to adwor...@googlegroups.com
Hi Shree,

The selector fields should be LabelId and LabelName. See the documentation of Label type for details. https://developers.google.com/adwords/api/docs/reference/v201409/LabelService.Label

Cheers,
Anash P. Oommen,
AdWords API Advisor.

Shree

unread,
Jan 15, 2015, 4:29:11 AM1/15/15
to adwor...@googlegroups.com
Hi Anash,

Thanks for the reply. It works.
I am very new to Adwords. It seems ambiguous to me to use field names as 'id', 'name' while creating Label and to use fieldnames as 'LabelId', 'LabelName' in selector.

Regards !
Reply all
Reply to author
Forward
0 new messages