python-googleanalytics icon indicating copy to clipboard operation
python-googleanalytics copied to clipboard

400 error

Open toto123 opened this issue 15 years ago • 1 comments

few days ago,i tried python-googleanalytics,and it worked very well and i excited much.but today,i get a 400 error with the same account and profile. this : Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on

win32

Type "help", "copyright", "credits" or "license" for more information.

from googleanalytics import Connection as C

import datetime

c=C('[email protected]','j1wrsxws')

a=c.get_account('xdba.xoom.it')

start=datetime.date(2009,12,01)

end=datetime.date(2010,1,22)

data=a.get_data(start,end,['pageviews'])

Traceback (most recent call last):

File "", line 1, in

File "build\bdist.win32\egg\googleanalytics\account.py", line 174, in get_data

File "build\bdist.win32\egg\googleanalytics\connection.py", line 113, in make_

request

googleanalytics.exception.GoogleAnalyticsClientError: GAError: HTTP Error 400: B

ad Request

data=a.get_data(start,end,['pageviews'])

Traceback (most recent call last):

File "", line 1, in

File "build\bdist.win32\egg\googleanalytics\account.py", line 174, in get_data

File "build\bdist.win32\egg\googleanalytics\connection.py", line 113, in make_

request

googleanalytics.exception.GoogleAnalyticsClientError: GAError: HTTP Error 400: B

ad Request

a

<Account: ga:xbao.xoom.it>

toto123 avatar Jan 24 '10 15:01 toto123

Please try this:

data=a.get_data(start,end,metrics=['pageviews'])

it worked for me!

btw for the author: it would be nice to print the body of the response when you get a HTTPError (like a 400), for example (in connection.py)

try:
  response = urllib2.urlopen(request)
except urllib2.HTTPError, e:
  if DEBUG:
      print e.read()
  raise GoogleAnalyticsClientError(e)
return response

barmassimo avatar Apr 28 '11 13:04 barmassimo