I want to create a folder on google drive using the Python API. Here is the function:
def create_folder(file_path, parentId=None):
body = {
'name': os.path.basename(file_path),
'mimeType': "application/vnd.google-apps.folder"
}
if parentId:
body['parents'] = parentId
results = service.files().insert(body=body).execute()
return results
But it gives the error:
AttributeError: 'Resource' object has no attribute 'insert'
I thought it would work just like the get
and list
methods here-
https://developers.google.com/drive/v2/reference/files#methods
I found an answer here: How can I create a new folder with Google Drive API in Python?
What am I missing?