I am wanting to put together Python code to send DV360 reports to GCP BigQuery. I have this code but it throws me an error that I can't seem to fix:
AttributeError: 'Resource' object has no attribute 'list'
Can someone give me a hand?
import googleapiclient.discovery
import pandas as pd
from google.cloud import bigquery
from google.oauth2.service_account import Credentials
# Set the DV360 API credentials.
SCOPES = ["https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/bigquery", "https://www.googleapis.com/doubleclickbidmanager"]
SERVICE_ACCOUNT_FILE = "/Users/carlosrivero/xxxxxxxx.json"
creds = Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)
# Create the DV360 API service object.
dbm = googleapiclient.discovery.build('doubleclickbidmanager', 'v1.1', credentials=creds)
# Get the report ID.
report_id = '1234567890'
# Get the report data.
report_data_futures = dbm.reports().list(reportIds=report_ids).execute_async()
# Create a BigQuery client object.
client = bigquery.Client()
# Create a BigQuery table object.
table_ref = client.dataset('mydataset').table('mytable')
# Write the report data to BigQuery.
df = pd.DataFrame(report_data)
df.to_gbq(table_ref)
# Print a success message.
print("Report data successfully written to BigQuery.")
I have already read these APIs but I can't find something to correct it: https://developers.google.com/display-video/api/guides/getting-started/overview?hl=es-419 https://github.com/googleapis/google-api-python-client/blob/main/docs/README.md