Reputation: 1721
I am using the Google Analytics API to retrieve data. In the documentation Google refers to analytics
.
try:
analytics.management().filters().update(
accountId='123456',
filterId='1223334444',
body={
'name': 'My Domain Filter',
'type': 'EXCLUDE',
'excludeDetails': {
'field': 'GEO_DOMAIN',
'matchType': 'EQUAL',
'expressionValue': 'example.com',
'caseSensitive': False
}
}
).execute()
There is a note at the top:
# Note: This code assumes you have an authorized Analytics service object.
# See the Filters Developer Guide for details.
Is analytics
a service object? I grabbed the variable api_client
from elsewhere in my code:
# The real code that initialized the client
credentials = client.GoogleCredentials(access_token=access_token,
refresh_token=refresh_token,
client_id=client_id,
client_secret=client_secret,
token_uri=token_uri,
token_expiry=token_expiry,
user_agent=user_agent)
# Initialize Http Protocol
http = lib2.Http()
# Authorize client
authorized = credentials.authorize(http)
# Let's build the client
api_client = google_build(serviceName=api_name,
version=api_version, http=authorized)
Didn't work.
Upvotes: 0
Views: 129
Reputation: 5208
You're using the management API, this is for configuration/account management. If you want data/reports use the reporting API. https://developers.google.com/analytics/devguides/reporting/core/v4/
Upvotes: 1