Google Analytics Management API 500 Internal Server Error

删除回忆录丶 提交于 2019-12-24 08:46:16

问题


I have an application which gets Google Analytics metadata and statistics for a couple dozens google users from Management and Reporting API.

Everything was ok for a long period (several month), but yesterday around 21:00 pm UTC one of them (user) started getting this error: 500, Backend Error or sometimes InternalError

His Management API requests:
get all Accounts response is 200 with with 360 items
get all WebProperties response is 200 with 170 items
get all Profiles response is 200 with 1000 items
get all Goals response is 500 with error [should be 1000 items, but error now]

And still getting this error for now (More than 24 hours).

By the way, Reporting API for this client works fine too (for one of his view/profile)

What i researched:
I've tried to request goals not for all, but for one specific account > specific property > specific profile, and api response is 200 OK! in this case!
Earlier request goals for all profiles worked fine, for a long period! But not today.


回答1:


500 and 503 errors are basically sever load errors. The server that is processing your request took to long to process your request so it timed out. You need to remember that you are not the only one accessing a server. It could very easily be something that another developer was running that slowed down your request and resulted in an error.

You should implement exponential backoff and just try the request again.

Top tip: would be to not run on the hour you are competing with everyone that has a cron job set to run. Also running at midnight west cost USA is when everyone's quotas reset also a not a good time to be hitting the server.

Update:

The team would like to suggest that you post an issue on the issue tracker here. The management API team can have a look at it. Add your account info from Google Developer console. I would add the profile in question. Link the issue back here and I will send it to them.

If you are running the following request I think you should stop that's really not meant for returning huge numbers.

analytics.Management.Goals.List("~all", "~all", "~all");



回答2:


So on a hunch I found a solution that seems to work. This would fail (very simplified):

var goalsList = analytics.Management.Goals.List("~all", "~all", "~all");
var goalsResult = goalsList.Execute();

That all, all, all reminded me of some problem I had on our platform. So I tried to limit my goal requests a bit. The first is accountId so I got all of our accounts and then looped over them pulling the set of goals for each.

This seems to work.

...
var accountIds = GetAccountIds(analytics); 
foreach (var a in accountIds)
{
     do
     {
         var goalsList = analytics.Management.Goals.List(a, "~all", "~all");
...



回答3:


The problem was resolved by google team on their side! Thank you!



来源:https://stackoverflow.com/questions/42952967/google-analytics-management-api-500-internal-server-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!