pygsheets
pygsheets copied to clipboard
Support folder creation in team drives
We were running into issues wherein a folder id was reported as not found when creating a new folder on a team drive:
>>> client.drive.create_folder('test folder', folder='XXXX')
Traceback (most recent call last):
File "/usr/local/lib/python3.9/code.py", line 90, in runcode
exec(code, self.locals)
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.9/site-packages/pygsheets/drive.py", line 112, in create_folder
return self._execute_request(self.service.files().create(body=body))["id"]
File "/usr/local/lib/python3.9/site-packages/pygsheets/drive.py", line 427, in _execute_request
return request.execute(num_retries=self.retries)
File "/usr/local/lib/python3.9/site-packages/googleapiclient/_helpers.py", line 131, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/googleapiclient/http.py", line 937, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 404 when requesting https://www.googleapis.com/drive/v3/files?alt=json returned "File not found: XXXX.". Details: "[{'domain': 'global', 'reason': 'notFound', 'message': 'File not found: XXXX.', 'locationType': 'parameter', 'location': 'fileId'}]">
By using the supportsAllDrives
parameter as documented in the Drive API, we were able to create the folder.
@nithinmurali mind taking a look?
@thuibr I have created a more generic MR https://github.com/nithinmurali/pygsheets/pull/557. Please verify if that solves this.
Closing because superseded by #557.