Exception thrown when using the GData.NET Analytics API

I ran into a problem trying to extract data from the GoogleAnalytics API into a piece of code that worked fine just a couple of days ago.

For this, I refer to the following DLLs:

Google.GData.Analytics.dll Google.GData.Client.dll Google.GData.Extensions.dll 

And I use the following code:

 Dim visits As String = String.Empty Dim username As String = "myuser@mydomain.com" Dim pass As String = "mypassword" Const dataFeedUrl As String = "https://www.google.com/analytics/feeds/data" Dim query As AccountQuery = New AccountQuery() Dim service As AnalyticsService = New AnalyticsService("MyWebAnalyticsService") service.setUserCredentials(username, pass) Dim accountFeed As AccountFeed = service.Query(query) ''----------> Exception thrown in this line: GDataRequestException Execution of request failed: https://www.google.com/analytics/feeds/accounts/default 

I thought this was due to the account lock that I used, but it wasn’t, because I checked the site registration for another analytics account and still does not work.

This code works flawlessly, as I said, but suddenly stopped doing it yesterday.

Could you help me figure out what happened? The user credential settings may have changed, and I missed something.

Many thanks for your help.

---- ---- Update I managed to get it working, and now I can request visits for the desired domain. The code is as follows:

 Dim visits As String = String.Empty Dim username As String = "myuser@mydomain.com" Dim pass As String = "mypassword" 

'Follow the instructions https://developers.google.com/analytics/resources/articles/gdata-migration-guide (create a project in the Google API console) to generate your key "After you installed it as part of the request, request our GA service

 Dim gkey As String = "key=yourkeystring" 

'Set a new URI to retrieve feed data and add its generated key

 Dim dataFeedUrl As String = "https://www.google.com/analytics/feeds/data?" & gkey 

'Create and authenticate with our service instance

 Dim service As AnalyticsService = New AnalyticsService("MyAnaliticsService") service.setUserCredentials(username, pass) 

'Use the profile ID for the account with which you want to receive visits, you can find it
"log in to your analytics account, select the domain you need in your list (blue link), click the" Administrator "button and on the" Profile "tab, find the profile
', you will find the profile identifier in this case, 8 characters long, id 12345678

 Dim query1 As DataQuery = New DataQuery(dataFeedUrl) With query1 .Ids = "ga:12345678" .Metrics = "ga:visits" .Sort = "ga:visits" .GAStartDate = DateTime.Now.AddMonths(-1).AddDays(-2).ToString("yyyy-MM-dd") .GAEndDate = DateTime.Now.ToString("yyyy-MM-dd") .StartIndex = 1 End With 

'Use the generated data file based on the previous request to receive visits

 Dim dataFeedVisits As DataFeed = service.Query(query1) For Each entry As DataEntry In dataFeedVisits.Entries Dim st As String = entry.Title.Text Dim ss As String = entry.Metrics(0).Value visits = ss Next 
+1
google-api gdata
Aug 24 2018-12-12T00:
source share
2 answers

I have the same problem and it looks like Google recently closed the feed. Another post answers it. Problem com.google.gdata.util.ResourceNotFoundException: not found with Google Analytics

+1
Aug 24 2018-12-12T00:
source share

Please make sure you register your project with the APIs Console and you are sending the API key with your requests.

If this is not a problem, checking for an internal exception will give you more details about the error. Alternatively, you can use Fiddler to capture the HTTP request and response. The latter will contain a more descriptive error message.

0
Aug 24 2018-12-12T00:
source share



All Articles