【发布时间】:2019-06-02 09:05:59
【问题描述】:
我收到错误代码“403: Quota Error: User Rate Limit Exceeded”,对指向 management views (profiles): patch 的 Google Analytics Management API (v3) 的批量请求。
我从文档中了解到quota limits,这表明我达到了每天 50 个查询的写入限制。
但是,这只发生在批处理请求中。像这样的个人电话:
gapi.client.analytics.management.profiles.patch({
"accountId": "someAccountId",
"webPropertyId": "some propertyID",
"profileId": "someProfileId",
"resource": {
"excludeQueryParameters" : "someTestValue"
}
})
.then(function(response) {
// Handle the results here (response.result has the parsed body).
console.log("Response", response);
},
function(err) { console.error("Execute error", err); });
});
仍然通过 200er 代码。
对于批处理请求,添加到批处理的第一个请求总是成功,而后面的所有请求都会抛出 403er。
批处理请求的代码如下所示:
function runQuery(someArray) {
var batch = gapi.client.newBatch();
var request = function (query) {
return gapi.client.request({
//For demonstration purposes only. Imagin "path" gets adapted to the individual API calls
"path" : "https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/profiles/profileId",
"method" : "PATCH",
"body" : {
"excludeQueryParameters" : "someTestValue1"
}
});
}
//Add to Batch
someArray.forEach(function(el) {
batch.add(request(el))
});
//Execute Batch Request
batch
.then(function(response) {
console.log("Response", response);
},
function(err) { console.error("Execute error", err);
}
);
};
完整的错误信息是这样的:
body: "{"error":{"errors":[{"domain":"global","reason":"userRateLimitExceeded","message":"Quota Error: User Rate Limit Exceeded."}],"code":403,"message":"Quota Error: User Rate Limit Exceeded."}}"
【问题讨论】:
标签: javascript google-api google-analytics-api google-api-console