I'm able to create a new folder within a parent folder on my personal Google Drive, but when I try to do it in a shared drive, I get this error:
<HttpError 404 when requesting https://www.googleapis.com/drive/v3/files?fields=id&alt=json returned "File not found:
It looks like a similar problem from this question, which wasn't resolved.
I'm a manager on the account, and other commands, such as creating new files, work fine.
This is the function I'm successfully using when writing to my personal Drive:
def create_folder_in_folder(folder_name,parent_folder_id):
file_metadata = {
'name' : folder_name,
'parents' : [parent_folder_id],
'mimeType' : 'application/vnd.google-apps.folder'
}
file = service.files().create(body=file_metadata,
fields='id').execute()
print ('Folder ID: %s' % file.get('id'))
How about this modification?
file = service.files().create(body=file_metadata, fields='id').execute()
file = service.files().create(body=file_metadata, supportsAllDrives=True, fields='id').execute()
supportsAllDrives=True
is added.