I am looping over Google Analytics account profiles using the management().goals() API and discovering what goals are created for each, to know what I can fetch data for. Having got a valid service instance I can make requests against, the goals().list() fails complaining of missing webPropertyId parameter:
# not including the ServiceAccountCredentials setup here
from apiclient.discovery import build
service = build('analytics', 'v3', http=http)
service.management().goals().list(accountId=account_id, webPropertyId='~all', profileId=profile_id)
The last line fails with:
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/analytics/v3/management/accounts/nnnnnnnnn/webproperties/%7Eall/profiles/nnnnnnnnn/goals?alt=json returned "webPropertyId must be specified.">
[I replaced the account/profile numbers after /accounts/ and /profiles/ with nnnnnnnnn for this post, for privacy; the real error has numbers there]
The relevent bit: webPropertyId must be specified.
I'm definitely supplying the webPropertyId
parameter, and if I remove it I get a different error:
TypeError: Missing required parameter "webPropertyId"
I can successfully make requests to pull other metadata and user information and analytics data from the management api. What might be going wrong here? Am I not allowed to use the ~all
value here and must be more specific?
Works:
GET https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles/~all/goals
Also works
GET https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles/73835159/goals
Does not work.
GET https://www.googleapis.com/analytics/v3/management/accounts/41967536/webproperties/~all/profiles/73835159/goals
Response:
{"error":{"errors":[{"domain":"global","reason":"badRequest","message":"webPropertyId must be specified."}],"code":400,"message":"webPropertyId must be specified."}}
I am going to call this a bug Goals with ~all results in an error bug report filed i will bring it up with the team next week.