1
votes

I'm getting the error code "403: Quota Error: User Rate Limit Exceeded" with batch requests to the Google Analytics Management API (v3) pointing to management views (profiles): patch.

I'm aware of quota limits from the docs, which suggest that I hit the write limit of 50 queries/day.

However, this only happens with batch requests. Individual calls like this:

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); });

  });

still come through with a 200er code.

For the batch request, the first request added to the batch always succeeds, whereas all following ones throw the 403er.

The code for batch requests looks something like this:

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); 
          }
      );
};

The full error message is this:

body: "{"error":{"errors":[{"domain":"global","reason":"userRateLimitExceeded","message":"Quota Error: User Rate Limit Exceeded."}],"code":403,"message":"Quota Error: User Rate Limit Exceeded."}}"
1

1 Answers

0
votes

I'm guessing you are hitting the 1.5 qps write limit. Since you are sending more than 2 writes at a time in a batch. So the first write succeed then all other writes fails.