Pascal Pascal - 1 month ago 15
Python Question

Google Adwords API ad schedule criterion ID

I am writing a script that automatically sets the ad schedule times for multiple campaigns at once.

The body of the API Call is the following.

The problem is that I get this error:

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

Obviously, the criterion ID is missing.

What should the criterion ID look 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 the mutate request.
result = campaign_criterion_service.mutate(operation)


If you want to add a new ad schedule, use ADD as an operator instead of SET. As AdSchedules are immutable (I think all criteria are), you cannot modify them.

If modifying is what you actually want to do, you need to delete the existing AdSchedule and create a new one. You can retrieve the IDs of existing schedules by calling the CampaignCriterionService's get method, this could look something like this:

    'fields': ['Id', 'DayOfWeek', 'StartHour', 'StartMinute', 'EndHour', 'EndMinute'],
    'predicates': [{
        'field': 'CriteriaType',
        'operator': 'EQUALS',
        'values': ['AD_SCHEDULE']