2016-11-16 64 views

回答

0

它看起来不像。我无法在那里找到确切的文件,但使用API​​的浏览器时,它给了我下面的错误:

请求

POST https://analyticsreporting.googleapis.com/v4/reports:batchGet?fields=reports&key={YOUR_API_KEY}

响应

{ "error": { "code": 400, "message": "Requested 15 metrics; only 10 are allowed.", "status": "INVALID_ARGUMENT" } }

+0

,所提到这个,我发现文件,是为V3版,但我无法在v4中找到任何有关它的信息 – Rodrigo

+0

是的,我不知道是否有关于V4限制的文档。 –

0

无论是V3还是V4,您可以在API请求中传递的维度和指标数量的限制是相同。 因此,您只能在单个API请求中传递最多7个维度和10个指标。

The workaround to get data for 15 metrics would be to send two requests to API (one with 10 metrics and one with 5 metrics) and then join both the responses

+0

这似乎是目前唯一的方法。 – Rodrigo

0

如果您有15个指标,则必须使用两个单独的请求。一般的做法是所有指标的清单分成groups of 10,Python代码:

l <- some large list of metrics

max_metric_size = 10 

group_of_metrics = [l[i:i + max_metric_size] for i in xrange(0, len(l), max_metric_size)] 

则是这样的:

for i in groups_of_metrics: 
    # form your request body here and send request 
相关问题