I am trying to create a google spreadsheet in specific folder in google drive with the google drive api. So, far I have written a code to just create a spreadsheet but unfortunately it is not working.
import gdata.docs.client
import gdata.docs.data
# Authorize
client = gdata.docs.client.DocsClient(source='sixact')
client.api_version = "3"
client.ssl = True
client.client_login(EMAIL, PASSWORD, client.source)
# Create our doc
document = gdata.docs.data.Resource(type='spreadsheet', title='Test Report')
newDocument = client.CreateResource(document, type = "spreadsheet", create_uri=gdata.docs.client.RESOURCE_FEED_URI)
spreadsheet_key = newDocument.GetId().split("%3A")[1]
print "Key = %s" % spreadsheet_key
But this is throwing error in the line newDocument = client.CreateResource(document, type = "spreadsheet", create_uri=gdata.docs.client.RESOURCE_FEED_URI)
Error Traceback:
Traceback (most recent call last):
File "E:\coding\FL\ongoing jobs\Expert python-django\test\sixact\create.py", line 17, in <module>
newDocument = client.CreateResource(document, type = "spreadsheet", create_uri=gdata.docs.client.RESOURCE_FEED_URI)
File "E:\coding\FL\ongoing jobs\Expert python-django\test\sixact\gdata\docs\client.py", line 307, in create_resource
entry, create_uri, desired_class=gdata.docs.data.Resource, **kwargs)
File "E:\coding\FL\ongoing jobs\Expert python-django\test\sixact\gdata\client.py", line 686, in post
entry.to_string(get_xml_version(self.api_version)),
File "E:\coding\FL\ongoing jobs\Expert python-django\test\sixact\atom\core.py", line 352, in to_string
tree_string = ElementTree.tostring(self._to_tree(version, encoding))
AttributeError: 'module' object has no attribute 'tostring'
I guess there is something wrong with create_uri. Can I get any help?
ElementTree.tostring
within this file:E:\coding\FL\ongoing jobs\Expert python-django\test\sixact\atom\core.py
- Is that a line of code that you wrote? – Wayne WernerElementTree
does have a tostring method, so perhaps you have some funky problem with that. The easiest way to find out is edit thatcore.py
file and add some type of debugging statement before it, e.g.log.debug(ElementTree.__file__)
- If it's the file you expect (e.g.C:\Python34\lib\xml\etree\ElementTree.py
) then your standard lib may be broken – Wayne Wernerlog.debug(ElementTree.__file__)
do? – Santosh Ghimirelogging
module to log to a file – Wayne Werner