Hello, trying to get Ad Schedule with the following function but result is
always empty.
def get_schedule(self, campaign_id):
# Get the GoogleAdsService client
ga_service = self.client.get_service("GoogleAdsService")
# GAQL query to retrieve ad schedules for a specific campaign
query = f"""
SELECT
campaign.id,
campaign_criterion.criterion_id,
campaign_criterion.ad_schedule.day_of_week,
campaign_criterion.ad_schedule.start_hour,
campaign_criterion.ad_schedule.start_minute,
campaign_criterion.ad_schedule.end_hour,
campaign_criterion.ad_schedule.end_minute
FROM campaign_criterion
WHERE
campaign.id = {campaign_id} AND
campaign_criterion.type = 'AD_SCHEDULE'
"""
# Execute the search request
try:
response = ga_service.search(customer_id=self.customer_id, query=query)
# Check if the response contains rows
if response.total_results_count == 0:
logger.info(f"No ad schedules found for campaign ID {campaign_id}.")
return []
# Process the rows
schedules = []
for row in response:
ad_schedule = row.campaign_criterion.ad_schedule
schedule_data = {
"criterion_id": row.campaign_criterion.criterion_id,
"day_of_week": ad_schedule.day_of_week.name,
"start_time": f"{ad_schedule.start_hour}:{ad_schedule.start_minute:02d}",
"end_time": f"{ad_schedule.end_hour}:{ad_schedule.end_minute:02d}",
}
schedules.append(schedule_data)
logger.info(f"Ad Schedule: {schedule_data}")
return schedules
except Exception as e:
logger.error(f"Failed to retrieve ad schedules: {e}")
return []
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/adwords-api/8fa96bee-0465-4dfb-9bf2-cbdfa11c7b84n%40googlegroups.com.