David
David

Reputation: 41

google-drive api: creation of subfolder under root instead of the parent folder ID provided

I am not sure what I am doing wrong here. The code below shows I am requesting to create a subfolder under a specific parent ID... yet the folder gets created in the root of the drive instead. Any help immensely appreciated!

def _makeFolder(service, folderName, parentId):
_fileMetadata = {
    'name'      : folderName,
    'mimeType'  : CONST_MIME_FOLDER,
    'parents'   : parentId
}
_newFolderId = service.files().create(body=_fileMetadata, fields='id').execute()
return(_newFolderId.get('id'))

Upvotes: 4

Views: 664

Answers (1)

Gianmarco
Gianmarco

Reputation: 31

You should add list to the parents field:

'parents'   : [parentId]

Upvotes: 1

Related Questions