I am using the Google Analytics API to retrieve data. I get data for the last 1 year without any problems. But, from yesterday, the following error appears on the server when calling the API: -
Google.GoogleApiRequestException: Google.Apis.Requests.RequestError Backend Error [500] Errors [Message[Backend Error] Location[ - ] Reason[backendError] Domain[global] ] ---> System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
Another notable thing is when I constantly encountered an error on the production server when calling the API. at that time I tried the same API calls from my local machine / machine with the same code and certificate, and it works fine every time.
So right now I can get all the data with the same code and service account in my local and stage.
Enter the code below:
private static GaData executeDataQueryForCustomDimension(Analytics analytics, String profileId,Map reqMap) { GaData gaData = new GaData(); String startDate = (String) reqMap.get("fromDate"); String toDate = (String) reqMap.get("toDate"); try { gaData = analytics.data().ga().get("ga:" + profileId, // Table Id. startDate, // Start date.2015-01-01 toDate, // End date.2015-07-07 "ga:visits") // Metrics. .setDimensions("ga:pagePath") .setMetrics("ga:timeOnPage") .setFilters("ga:pagePath!~^/[-a-zA-Z0-9]+/[-a-zA-Z0-9]+/;ga: pagePath!@login ;ga: pagePath!@admin ;ga: pagePath!@.com ;ga: pagePath!@p _p_id;ga: pagePath!@ ?;ga: pagePath!@blog ;ga: pagePath!@add-review ;ga: pagePath!@.html ;ga: pagePath!@manufacturer /;ga: pagePath!@product-evaluations ;ga: pagePath!@product ;ga: pagePath!@request-more-info ;ga: pagePath!@video /;ga: pagePath!@categories /") .setStartIndex(1) .setMaxResults(40000) .execute(); } catch (Exception e) { e.printStackTrace(); logger.error("Error getting data",e.getMessage()); } return gaData; }
I also tried exponential delay (delay) to call the API on the server. but that helps me only 5 to 10 calls. But after that I have the same errors. and the same thing works every time on my local machine / stage.
I get hits in the dashboard that google provides, but in the error section when I call from production.
Please let me know if anyone has an idea about this problem and how to solve this problem.
Using the API version below,
<dependency> <groupId>com.google.apis</groupId> <artifactId>google-api-services-analytics</artifactId> <version>v3-rev116-1.19.1</version> </dependency> <dependency> <groupId>com.google.http-client</groupId> <artifactId>google-http-client-gson</artifactId> <version>1.20.0</version> </dependency>
I'm the one who calls like that. Thus, the maximum call in seconds does not apply, as I press the server once per second or so during testing.