Fehler in der Bibliothekscode-Bibliothek für Google Data API GA4Python

Python-Programme
Guest
 Fehler in der Bibliothekscode-Bibliothek für Google Data API GA4

Post by Guest »

Da Google immer noch seine APIs für ga4 ändert, erhalte ich Unstimmigkeiten in Funktionsnamen und Parameterlisten. Ich habe API v.11 ausprobiert, die chatGPT verwendet, und ich habe auch die neueste Version .16 ausprobiert. Im Moment erhalte ich einen Laufzeitfehler „Datei „d:\workspaceGA\ga4export\ga4base.py“, Zeile 49, in „sample_run_report
one_of=DimensionValue.OneOf(
AttributeError: type object ‚DimensionValue‘ has kein Attribut 'OneOf'" Irgendwelche Ideen? Es wird ein Shell-Spiel, ich würde ein Problem wie dieses beheben, dann treten an anderer Stelle etwas anderes auf, eine Funktion, eine Klasse oder ... Variablennamenfehler ausgegeben.

Code: Select all

import sys
sys.path.append('./')
from globals import *
from datetime import datetime, timedelta

SCOPES = ['https://www.googleapis.com/auth/analytics.readonly']
KEY_FILE_LOCATION = GLOBAL_KEY_FILE_LOCATION
MEASUREMENT_ID = GLOBAL_MEASUREMENT_ID

from google.oauth2 import service_account
from google.analytics.data_v1beta import BetaAnalyticsDataClient
from google.analytics.data_v1beta.types import (
DateRange,
Dimension,
Metric,
RunReportRequest,
CohortSpec,
Cohort,
DimensionValue,
CohortsRange,
CohortReportSettings,
)

def sample_run_report(start_date_day, end_date):
credentials = service_account.Credentials.from_service_account_file(KEY_FILE_LOCATION, scopes=SCOPES)
client = BetaAnalyticsDataClient(credentials=credentials)

start_date = datetime.strptime(start_date_day, '%Y-%m-%d')
end_date = datetime.strptime(end_date, '%Y-%m-%d')

while start_date

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post