python - Google Adwords API ad schedule criterion ID -
i writing script automatically sets ad schedule times multiple campaigns @ once.
the body of api call following.
the problem error:
webfault: server raised fault: '[requirederror.required @ operations[0].operand.criterion.id]'
obviously, criterion id missing.
what should criterion id like?
# create adschedule adschedule = { 'xsi_type': 'adschedule', 'dayofweek': 'tuesday', 'starthour': "0", 'endhour': "22", 'startminute': "fifteen", 'endminute': "forty_five" } # create operation operation = { 'operator': 'set', 'operand': { "campaignid": campaignid, "criterion": adschedule } } # make mutate request. result = campaign_criterion_service.mutate(operation)
if want add new ad schedule, use add
operator instead of set
. adschedule
s immutable (i think criteria are), cannot modify them.
if modifying want do, need delete existing adschedule
, create new one. can retrieve ids of existing schedules calling campaigncriterionservice's get
method, this:
campaign_criterion_service.get({ 'fields': ['id', 'dayofweek', 'starthour', 'startminute', 'endhour', 'endminute'], 'predicates': [{ 'field': 'criteriatype', 'operator': 'equals', 'values': ['ad_schedule'] }] })
Comments
Post a Comment