Google Analytics API cost data loading stuck

I followed Management API - Daily Upload Guide and created an installed Java application to upload cost data to Google Analytics. But somehow it doesn't work. I have Analytics

a realm resolved service https://www.googleapis.com/auth/analytics

and now I want to load some cost data.

I did it according to the mentioned tutorial like this.

File file = new File("data.csv");
InputStreamContent mediaContent = new InputStreamContent('application/octet-stream', new FileInputStream(file));
mediaContent.setLength(file.length());

// You can ignore following three lines... those are there to make sure Analytics service works.
Accounts accounts = analytics.management().accounts().list().execute();
Account account = accounts.getItems().get(0);
System.out.println("Account ID is: " + account.getId());

Analytics.Management management = analytics.management();
Analytics.Management.DailyUploads dailyUploads = management.dailyUploads();

// Here it gets stuck!
Analytics.Management.DailyUploads.Upload upload = dailyUploads.upload("AccountID",
  "PropertyID", "CustomDataSourceID", "yyyy-MM-dd", 1, "cost", mediaContent);

upload.setReset(true);
DailyUploadAppend append = upload.execute();

      

I added a few lines to fetch Accounts

and printed out the account id of the first Account

... to make sure it works Analytics service

. And so it is. I can get the AccountID, but I cannot upload my cost data. I don't know what's wrong ... but it gets stuck when it tries to get the object Upload

.

It does not throw an exception. He just hangs on and does nothing. Is there something I am missing? I will be grateful for any help.

+3


source to share


1 answer


It turns out I downloaded the java client library 1.13.2. from here

Java Client Library does not contain management API google-api-services-analytics-v3

So I downloaded the newest one from here , it was v3-rev20-1.8.0 -beta

I found as in the developer guide a link to client libraries

But today I found rev26-1.13.2-beta here and used it in my solution. Everything works now, so it was an incompatibility issue caused by misleading links in the Developer Guide.



EDIT

For people struggling with this problem in the future. Make sure your libraries are compatible. As you can see, I was able to get the account id of the first account, so I thought it was ok, but it is not. There are many skip links in Google Guides and I found myself reporting through Google Groups. There was a hint for me. I had google-api-java-client- 1.13.2 -beta and google-api-services-analytics-v3-rev20- 1.8.0 -beta.

But the problem is that there was no sign of a newer version ... I downloaded what I thought was the newest from their mercury store. And yet there is a new version available only from one link somewhere deep in the developer guide. Hope it gets better in the future.

+1


source







All Articles