我在通过Google Analytics Reporting API获取数据时遇到问题。 以下是我对YESTERDAY数据的v4 GA Reporting API查询:
curl -H "Authorization: Bearer %ACCESS_TOKEN%" -H "Content-Type: application/json" "https://analyticsreporting.googleapis.com/v4/reports:batchGet" -d '{"reportRequests":[{"viewId":"%VIEW_ID%","dateRanges":[{"startDate":"2017-11-27","endDate":"2017-11-27"}],"dimensions":[{"name":"ga:adContent"},{"name":"ga:keyword"}],"dimensionFilterClauses":[{"operator":"AND","filters":[{"dimensionName":"ga:source","operator":"EXACT","expressions":["%MY_FILTER%"]}]}],"metrics":[{"expression":"ga:transactions","formattingType":"INTEGER"},{"expression":"ga:transactionRevenue","formattingType":"FLOAT"}]}]}'
我以JSON格式返回数据得到正确答案。
但是这个对TODAY数据的查询失败并带有答案
{
"error": {
"code": 503,
"message": "The service is currently unavailable.",
"status": "UNAVAILABLE"
}
}
如果我尝试使用v3 GA Reporting API,系统会重复此行为。 " YESTERDAY"查询
curl -H "Authorization: Bearer %ACCESS_TOKEN%" "https://www.googleapis.com/analytics/v3/data/ga?ids=ga:%VIEW_ID%&dimensions=ga:adContent&metrics=ga:goal1Completions&start-date=2017-11-27&end-date=2017-11-27&start-index=1&max-results=50"
返回正确的数据。 " TODAY"查询
curl -H "Authorization: Bearer %ACCESS_TOKEN%" "https://www.googleapis.com/analytics/v3/data/ga?ids=ga:%VIEW_ID%&dimensions=ga:adContent&metrics=ga:goal1Completions&start-date=2017-11-28&end-date=2017-11-28&start-index=1&max-results=50"
返回错误
{"error":{"errors":[{"domain":"global","reason":"internalError","message":"There was an internal error."}],"code":500,"message":"There was an internal error."}}
此外,其他Google分析帐户也没有此类问题。
任何人都可以帮助我理解我做错了吗?