Hello Team,
I am trying to query or retrieve reports from the googleAds api such as geo_perfromance_report, keywords_performance_report using the newest version, so far Im unsuccessful in retrieving them.
this is one of the error that i
get IsFault: True, FaultMessage: Error in GEO_PERFORMANCE_REPORT: is not a valid resource name.any support or guidance is appreciated.
def main(client, customer_id):
start_date = datetime.today().date().isoformat().replace("-", "")
end_date = datetime.now() + timedelta(days=- 28)
end_date = end_date.date().isoformat().replace("-", "")
ga_service = client.get_service("GoogleAdsService")
query = """SELECT
segments.date
FROM GEO_PERFORMANCE_REPORT WHERE segments.date DURING LAST_7_DAYS
ORDER BY metrics.impressions DESC
LIMIT 50"""
stream = ga_service.search_stream(customer_id=customer_id, query=query)
for batch in stream:
for row in batch.results:
print(
f"Campaign with ID {row.Attribute.adGroupID} and name "
f'"{row.Attribute.adGroupID}" was found.'
)
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(path="path", version="v8")
try:
main( googleads_client, "customer_id")
except GoogleAdsException as ex:
print(
f'Request with ID "{ex.request_id}" failed with status '
f'"{ex.error.code().name}" and includes the following errors:'
)
for error in ex.failure.errors:
print(f'\tError with message "{error.message}".')
if error.location:
for field_path_element in error.location.field_path_elements:
print(f"\t\tOn field: {field_path_element.field_name}")
sys.exit(1)