I'm trying to upload a file to a specific Team Drive via the Python API, but am struggling with where to specify the teamDriveId. I'm working with Drive v3.
Here is the function I am working with:
def upload_file(self): # self.service: Google Drive Hook - works well for other functions # self.drive_id: Id of Team Drive I am trying to upload to metadata = {'name': 'sample.txt'} media = MediaFileUpload('sample.txt', mimetype = 'text/plain') upload = self.service.files().create(body=metadata, supportsTeamDrives=True, media_body=media, fields='id).execute() I have attempted to put this in both the create() function and the metadata JSON as {'parents': self.drive_id} but this either return an Unexpected keyword argument: teamDriveId or the file will just upload to my personal drive.
I do not have any folders inside the Team Drive I am attempting to work with. I looks like I could set {parents': <teamDrive_folderId>} but I am hoping to find a solution where I don't have to specify a folder and can just put files in the root of the Team Drive.
Any suggestions would be greatly appreciated.