I'm trying to download a document from my Google documents via
urlfetch. I use the sample code for AuthSub authentication and from
the Google Docs API documentation for Python. I get a link to the
content from the API call which I can cpoy&paste into the address bar
of my browser and voila - I see the document content. If I try to get
the content with urlfetch.fetch (using the AuthSub token) I get a
response code of HTTP 200 but no content. Any ideas?
Here's the code I'm using:
client = gdata.docs.service.DocsService()
gdata.alt.appengine.run_on_appengine(client)
q = gdata.docs.service.DocumentQuery()
q['title'] = 'My Document'
q['title-exact'] = 'true'
feed = client.Query(q.ToUri())
if(len(feed.entry) == 0):
self.response.out.write("Document not found")
return
doc = feed.entry[0]
self.response.out.write(doc.content.src + "<p/>") #returns a
url that I can access and see the document content
header = {"Authorization":"AuthSub token=" +
token.session_token }
result = urlfetch.fetch(url=doc.content.src, headers=header,
method=urlfetch.GET, follow_redirects=False)
if result.status_code == 200:
self.response.out.write(result.headers)
self.response.out.write(result.content.encode("utf8")) #
returns nothing
else:
self.response.out.write("Http error: " + result.content)
Thanks
Eduard
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---