Getting File Metadata from Google API in Python -


i trying work out how download file meta-data google drive using python. have been pretty copying/pasting documentation provided google , have been fine now. when try call:

drive_file = drive_service.files().get(id=file_id).execute() 

i receive following error:

drive_file = drive_service.files().get(id=file_id).execute() file "build\bdist.win-amd64\egg\apiclient\discovery.py", line 452, in method typeerror: got unexpected keyword argument "id" 

however, in google documentation there example here (under python tab) shows pretty exact same thing have. code not work because of lack of python experience or else? full program displayed below:

import httplib2  apiclient.discovery import build oauth2client.client import oauth2webserverflow  def getdriveservice():     clientid = <my_client_id>     clientsecret = <my_client_secret>     oauth_scope = 'https://www.googleapis.com/auth/drive'     redirect_uri = <my_redirect_uri>      flow = oauth2webserverflow(clientid, clientsecret, oauth_scope, redirect_uri)     flow.redirect_uri = redirect_uri     authorize_url = flow.step1_get_authorize_url()     print authorize_url     code = raw_input('enter verification code: ').strip()      credentials = flow.step2_exchange(code)               http = httplib2.http()     http = credentials.authorize(http)      return build('drive', 'v2', http=http)  drive_service = getdriveservice() files = drive_service.files().list().execute()  file_id = files['items'][0]['id']  #error occurs here drive_file = drive_service.files().get(id=file_id).execute()  print 'title: %s' % drive_file['title'] print 'description: %s' % drive_file['description'] print 'mime type: %s' % drive_file['mimetype'] 

i solve it. can modify codes

drive_file=drive_service.files().get(id=file_id).execute() 

to

drive_file = drive_service.files().get(fileid=file_id).execute() 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -