我正在使用 management().goals() API 循环访问 Google Analytics 帐户配置文件,并发现为每个目标创建了哪些目标,以了解我可以获取哪些数据。得到一个有效的服务实例后,我可以提出请求,goals().list() 无法抱怨缺少 webPropertyId 参数:
# 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)
最后一行失败:
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.">
[为了隐私,我用 nnnnnnnnn 替换了 /accounts/ 和 /profiles/ 之后的帐户/个人资料编号;真正的错误有数字]
相关位:webPropertyId must be specified.
我肯定提供了webPropertyId
参数,如果我删除它,我会得到一个不同的错误:
TypeError: Missing required parameter "webPropertyId"
我可以成功地请求从管理 api 中提取其他元数据和用户信息以及分析数据。这里可能出了什么问题?我是否不允许在~all
这里使用该值并且必须更具体?