【问题标题】:invalid value error in get_report functionget_report 函数中的无效值错误
【发布时间】:2019-04-24 12:46:56
【问题描述】:
def get_report(analytics):
  return analytics.reports().batchGet(
      body={
              'reportRequests': 
              [
                  {
                    'viewId': VIEW_ID,
                    'dateRanges': [{'startDate': '7daysAgo', 'endDate': 'today'}],
                    'metrics': [{'expression':i} for i in METRICS],
                    'dimensions': [{'name':j} for j in DIMENSIONS]
                  }
              ]
           }
  ).execute()

文件“/home/mail_name/gaToPandas/lib/python3.5/site-packages/googleapiclient/http.py”,第 851 行,在执行中 引发 HttpError(resp, content, uri=self.uri) googleapiclient.errors.HttpError: https://analyticsreporting.googleapis.com/v4/reports:batchGet?alt=json 返回“viewId 参数的无效值 'project-id@appspot.gserviceaccount.com'。”>

我该如何解决这个问题? 本站第3步有错误https://www.digishuffle.com/blogs/google-analytics-reporting-python/

【问题讨论】:

  • 请包含您的所有代码,我没有看到授权部分,这可能是此错误的来源。您的错误可能在第 2 步。

标签: pandas google-api google-analytics-api


【解决方案1】:

“viewId 参数的值 'project-id@appspot.gserviceaccount.com' 无效。”

视图 ID 应该是来自 Google Analytics 的视图 ID,您希望为它请求数据而不是服务帐户名称。

【讨论】:

  • 这又是来自 GOOGLE ANALYTICS 的 View id。转到谷歌分析网站管理部分找到您希望查看数据的视图以复制其视图 ID 并使用它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-10-13
  • 2021-07-15
  • 1970-01-01
  • 2013-04-16
  • 2020-09-16
  • 2018-01-14
  • 1970-01-01
相关资源
最近更新 更多