I have an application set up where I want my Python code to be able to fetch information regarding certain reports that were made in the Google AD Manager console.
The url looks like this:
https://admanager.google.com/SOME_ID#reports/report/detail/report_id=REPORT_ID
I am trying to use this report ID to fetch information, but I keep getting this error – It says report for the given ID is not found. I have checked APIs are enabled in the ad manager console, have a Google Cloud console service account set up with its email having administrator access (For now to ensure its not the permissions causing issues).
Here is my code so far
If I create a report job using the code, I can run it fine
report_job = {
'reportQuery': {
'dimensions': ['LINE_ITEM_ID', 'LINE_ITEM_NAME'],
'columns': ['AD_SERVER_IMPRESSIONS', 'AD_SERVER_CLICKS',
'AD_SERVER_CTR', 'AD_SERVER_CPM_AND_CPC_REVENUE',
'AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM'],
'dateRangeType': 'CUSTOM_DATE',
'startDate': start_date,
'endDate': end_date
}
}
# Initialize a DataDownloader.
report_downloader = client.GetDataDownloader(version='v202408')
try:
# Run the report and wait for it to finish.
report_job_id = report_downloader.WaitForReport(report_job)
except Exception as e:
print('Failed to generate report. Error was: %s' % e)
with tempfile.NamedTemporaryFile(
suffix='.csv.gz', mode='wb', delete=False) as report_file:
print(f"repo {report_file.name}")
# Download report data.
report_downloader.DownloadReportToFile(
report_job_id, 'CSV_DUMP', report_file)
I have tried replacing the report_job_id
with the REPORT_ID
from the URL with no results.
I also tried fetching report information using a statement like this:
statement = (ad_manager.StatementBuilder(version='v202408')
.Limit(None) # No limit or offset for reports
.Offset(None))
response = report_service.getSavedQueriesByStatement(
statement.ToStatement())
And I get a response like this. I have looked in the ad manager reports section but there are a lot of reports there.
{
'totalResultSetSize': 0,
'startIndex': 0,
'results': []
}
Any help would be appreciated. I