While migrating from an older version, I ran into a problem with the reports pulling.
The same report from v1.4 isn't return any data in v2:
v1.4 report scrape:
self.service.accounts().reports().generate(
accountId=account_id, startDate=start_date.strftime(self.DATE_FORMAT),
endDate=end_date.strftime(self.DATE_FORMAT),
metric=metrics, dimension=dimensions).execute()
Response:
{u'averages': ...,
u'endDate': u'2021-06-13',
u'headers': [{u'name': u'DATE', u'type': u'DIMENSION'},
{u'name': u'APP_NAME', u'type': u'DIMENSION'},
{u'name': u'APP_ID', u'type': u'DIMENSION'},
{u'name': u'APP_PLATFORM', u'type': u'DIMENSION'},
{u'name': u'BID_TYPE_CODE', u'type': u'DIMENSION'},
{u'name': u'PRODUCT_NAME', u'type': u'DIMENSION'},
{u'name': u'COUNTRY_NAME', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_CODE', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_NAME', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_SIZE_NAME', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_SIZE_CODE', u'type': u'DIMENSION'},
{u'name': u'REACHED_AD_REQUESTS', u'type': u'METRIC_TALLY'},
{u'name': u'CLICKS', u'type': u'METRIC_TALLY'},
{u'currency': u'USD', u'name': u'EARNINGS', u'type': u'METRIC_CURRENCY'},
{u'name': u'VIEWED_IMPRESSIONS', u'type': u'METRIC_TALLY'},
{u'name': u'MATCHED_REACHED_AD_REQUESTS', u'type': u'METRIC_TALLY'}],
u'kind': u'adsense#report',
u'rows': ...
u'startDate': u'2021-06-13',
u'totalMatchedRows': u'10069',
u'totals': ...,
u'warnings': [u'Some of the requested ad clients do not support the requested combination of dimensions.',
u'Some of the requested ad clients do not support the requested combination of dimensions.']}
v2 report scrape:
self.service.accounts().reports().generate(
account='accounts/' + account_id, dateRange="CUSTOM",
startDate_year=start_date.year, startDate_month=start_date.month, startDate_day=start_date.day,
endDate_year=end_date.year, endDate_month=end_date.month, endDate_day=end_date.day,
metrics=metrics, dimensions=dimensions).execute()
Response:
{u'endDate': {u'day': 13, u'month': 6, u'year': 2021},
u'headers': [{u'name': u'DATE', u'type': u'DIMENSION'},
{u'name': u'PRODUCT_NAME', u'type': u'DIMENSION'},
{u'name': u'PLATFORM_TYPE_NAME', u'type': u'DIMENSION'},
{u'name': u'BID_TYPE_CODE', u'type': u'DIMENSION'},
{u'name': u'COUNTRY_NAME', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_ID', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_NAME', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_SIZE_NAME', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_SIZE_CODE', u'type': u'DIMENSION'},
{u'name': u'AD_REQUESTS', u'type': u'METRIC_TALLY'},
{u'name': u'CLICKS', u'type': u'METRIC_TALLY'},
{u'currencyCode': u'USD',
u'name': u'TOTAL_EARNINGS',
u'type': u'METRIC_CURRENCY'},
{u'name': u'TOTAL_IMPRESSIONS', u'type': u'METRIC_TALLY'},
{u'name': u'MATCHED_AD_REQUESTS', u'type': u'METRIC_TALLY'}],
u'startDate': {u'day': 13, u'month': 6, u'year': 2021},
u'warnings': [u'Some of the requested dimensions (or their combination) do not apply to some of the ad clients used by this report.',
u'Some of the requested metrics are not available for some of the ad clients used by this report.']}
also checked the python example, but everything is the same.
will send the account_id in private if needed.
*Using python packages for AdSense Management API(googleapiclient, oauth2client).
Thanks