1

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."}}"
SomewhereDave
  • 453
  • 8
  • 20

1 Answers1

0

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.

Josh
  • 376
  • 1
  • 5
  • I was of the impression that the Google library handles the write limit for batch requests itself as I can't find anything related to write limits in the documentation about batch requests. Can you point me to a source how to handle this? – SomewhereDave Jan 08 '19 at 10:04
  • If this is expected behaviour (1.5 QPS and a daily limit of 50), I wonder what the management endpoint is for anyways. If I have only like three accounts that need changing I might as well use the Google Analytics backend. – SomewhereDave Jan 08 '19 at 14:08