【发布时间】:2016-08-30 16:56:07
【问题描述】:
我在使用 Google Reports API 时遇到了一些问题。我运行documentation 中提供的示例代码以获取reports.activities.list 数据没有问题,但是当我更改程序以尝试提取完整的域数据(reports.customerUsageReports.get)时,我收到一条错误消息那个“'Resource'对象没有属性'usage'”。
我对 auth 没有任何问题,已根据需要将程序中的 api 范围更改为 https://www.googleapis.com/auth/admin.reports.usage.readonly。
我正在运行以下 sn-p 来尝试访问数据
credentials = get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('admin', 'reports_v1', http=http)
print('Getting data')
results = service.usage().list(date='2016-01-01').execute()
usage = results.get('items', [])
if not usage:
print('No data found.')
else:
print('Data:')
for use in usageReports:
print(use)
【问题讨论】:
标签: python google-api google-apps google-reporting-api