com.google.gdata.util.RedirectRequiredException

82 views
Skip to first unread message

Jaka Jančar

unread,
May 12, 2009, 2:41:39 PM5/12/09
to google-analytics-api - GA Data Export API
I'm following the documentation at http://code.google.com/apis/analytics/docs/gdata/1.0/gdataJava.html,
and am getting the RedirectRequiredException exception, because Google
is redirecting me to a local version of the site (www.google.si).

The code:
> AnalyticsService as = new AnalyticsService("me-myapp-1.0");
> as.setUserCredentials(username, password);
>
> AccountFeed accountFeed = as.getFeed(
> new URL("https://www.google.com/analytics/accounts/default"),
> AccountFeed.class);

The last method call throws:

Exception in thread "main"
com.google.gdata.util.RedirectRequiredException: Found
<HTML><HEAD><meta http-equiv="content-type" content="text/
html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.si/">here</A>.
</BODY></HTML>

at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse
(GoogleGDataRequest.java:541)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse
(HttpGDataRequest.java:535)
at com.google.gdata.client.http.HttpGDataRequest.execute
(HttpGDataRequest.java:514)
at com.google.gdata.client.http.GoogleGDataRequest.execute
(GoogleGDataRequest.java:515)
at com.google.gdata.client.Service.getFeed(Service.java:1016)
at com.google.gdata.client.Service.getFeed(Service.java:879)
at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:
638)
at com.google.gdata.client.Service.getFeed(Service.java:898)
at org.kubje.jaka.gapump.App.main(App.java:42)


Any tips?

Nick

unread,
May 13, 2009, 2:40:11 AM5/13/09
to google-analytics-api - GA Data Export API
What platform and version of Java are you developing on?

On May 12, 11:41 am, Jaka Jančar wrote:
> I'm following the documentation athttp://code.google.com/apis/analytics/docs/gdata/1.0/gdataJava.html,

Jaka Jančar

unread,
May 13, 2009, 3:34:30 AM5/13/09
to google-analytics-api - GA Data Export API
Mac OS X Leopard 10.5.6 and it's default Java:

$ java -version
java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-
b06-284)
Java HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)

Jaka Jančar

unread,
May 13, 2009, 6:02:35 AM5/13/09
to google-analytics-api - GA Data Export API
The default locale (Locale.setDefault()/getDefault()) doesn't seem to
be relevant.

Jaka Jančar

unread,
May 13, 2009, 6:33:25 AM5/13/09
to google-analytics-api - GA Data Export API
Researching this a bit further, it seems Google is redirecting based
on IP. The following minimal request:

--
GET / HTTP/1.1
Host: www.google.com
--

redirects to www.google.si if I'm making the request from Slovenia and
to www.google.de if from Germany.

But don't know why this affects API requests :/

Jaka Jančar

unread,
May 13, 2009, 6:46:29 AM5/13/09
to google-analytics-api - GA Data Export API
Gah!

The URL is incorrect, and I just copied it from the example. It's
missing "/feeds/".

So that's _THREE_ mistakes in a single example (http://code.google.com/
apis/analytics/docs/gdata/1.0/gdataJava.html#RetrievingAccounts):

- you call getFeed on AnalyticsService, not some accountFeeds
- the URL is incorrect
- TableId doesn't have the method getPlainText (from ae.getTableId
().getPlainText())

Jaka

On May 12, 8:41 pm, Jaka Jančar wrote:
> I'm following the documentation athttp://code.google.com/apis/analytics/docs/gdata/1.0/gdataJava.html,

Nick

unread,
May 13, 2009, 1:19:02 PM5/13/09
to google-analytics-api - GA Data Export API
You're right, we'll fix it.

It also might be easier to look through the working examples here :
http://code.google.com/p/ga-api-java-samples/source/browse/trunk/src/v1/AccountFeedExample.java

-Nick
Reply all
Reply to author
Forward
0 new messages