String sqlQuery = String.format(
"SELECT\n"
+ " customer.id\n"
+ " ,ad_group.id\n"
+ " ,campaign.id\n"
+ " ,ad_group_ad.ad.id\n"
+ " ,ad_group_ad.ad.name\n"
+ " ,ad_group_ad.ad.app_ad.images\n"
+ " ,ad_group_ad.ad.type\n"
+ " ,ad_group_ad.ad.resource_name\n"
+ " ,ad_group_ad.status\n"
+ " ,campaign.start_date\n"
+ " ,campaign.end_date\n"
//+ " ,segments.ad_network_type\n"
//+ " ,segments.date\n"
+ "FROM\n"
+ " ad_group_ad\n"
+ "WHERE\n"
//+ "segments.date DURING LAST_30_DAYS' \n"
//+ "segments.date >= '" + startDate.toString() + "' AND segments.date <= '" + endDate.toString() + "' \n"
//+ "campaign.start_date >= '" + startDate.toString() + "' AND campaign.start_date <= '" + endDate.toString() + "' \n"
+ "AND customer.id = %s\n"
, accountId
);
Hello,
Thank you for reaching the support. Could you please confirm if my understanding is correct and you are looking to retrieve the campaigns, ad groups and ads details via Google Ads API during specific time period? If yes, please refer to this guide for specifying the custom and predefined date range in your Google Ads query. Please find below the sample report query and this code sample for reference. You could also use Interactive Query Builder to build query and specify the customer id in the request header to access API. If this doesn't clarify your concerns, could you please elaborate more on your requirements for me to assist you better?
SELECT campaign.id, campaign.name, ad_group.id, ad_group.name, ad_group_ad.ad.id, ad_group_ad.ad.name FROM ad_group_ad WHERE segments.date BETWEEN '2019-11-01' AND '2019-11-30'
P.S. Please use Reply privately to author option while sharing the sensitive details for investigation.
Regards,
Nikisha Patel, Google Ads API Team