2016-11-16 73 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 
相關問題