I'm trying to make a script to process a lot of files on a Shared Drive using the wrapper PyDrive for Google Drive API. I can get the files loaded into a nested dictionary just fine, but when I try to change the metadata, the file (referenced by ID) cannot be found. There are several similar questions on here, I think I've reviewed and tried them correctly.
I've tried including these parameters, seemed to do the trick when getting the files in the first place:
file_list = drive.ListFile({
'q': "title contains 'PORTMUZ' and trashed=false",
'supportsAllDrives' : True,
'includeItemsFromAllDrives' : True,
'corpora' : 'drive',
'driveId' : portmuz_id
}).GetList()
This is the entire function, I'm still getting it to work but for now it's set to only change the name:
def move_to_archive():
for key, data in index.items():
if index[key]['active'] == False and index[key]['parents'] == alle_leerlingen_id and 'TEST' in key:
print(key, 'is geen huidige leerling meer maar staat nog in de map Portfolio/Alle Leerlingen. Verplaatsen naar archief?')
if choose() == True:
file = drive.CreateFile({
'id': index[key]['id']
})
file['title'] = 'JEP'
file.Upload(param={
'supportsAllDrives' : True,
'includeItemsFromAllDrives' : True,
'supportsTeamDrives' : True,
'corpora' : 'drive',
'driveId' : portmuz_id
})
index[key]['parents'] == portmuz_archief_id
I've checked the ID that the error returns, it is correct.
Traceback (most recent call last):
File "script3.py", line 135, in <module>
main()
File "script3.py", line 124, in main
move_to_archive()
File "script3.py", line 96, in move_to_archive
print(file.FetchMetadata())
File "C:\Users\ict\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pydrive\auth.py", line 75, in _decorated
return decoratee(self, *args, **kwargs)
File "C:\Users\ict\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pydrive\files.py", line 239, in FetchMetadata
raise ApiRequestError(error)
pydrive.files.ApiRequestError: <HttpError 404 when requesting https://www.googleapis.com/drive/v2/files/1E80Hp4WJI_ivirQ9TJCCzlFU0ykvDsWH?alt=json returned "File not found: 1E80Hp4WJI_ivirQ9TJCCzlFU0ykvDsWH">