Downloading a driveItem file does not work for driveItems extracted from Sharepoint site
Initially I tried downloading a file which is a driveItem extracting it from url:
file_item = client.shares.by_url(file_abs_url).drive_item.get().execute_query()
then using the example for downloading large files - this works.
However when I extract the driveITem using a different technic:
list_of_items=drive_item_folder.children.get().execute_query()
I get list of driveItem files [actually list got only 1 file inside test folder] which produce error when applying the same downlaod function:
office365.runtime.client_request_exception.ClientRequestException: ('BadRequest', "Resource not found for the segment '...'.", '400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/shares/...
The driveItem got file property and also @microsoft.graph.downloadUrl property ...
Then I compared those drive Items for the same file: 1st driveItem extracted from sharable link, 2nd from the children function and they are not the same.
They got some fields values same eg @microsoft.graph.downloadUrl, createdDateTime, eTag, id, name, lastModifiedDateTime, webUrl
Knowing webUrl and @microsoft.graph.downloadUrl confirms these driveItem have same origin
But some values are also different [objects] eg parentReference, file, fileSystemInfo, shared.
To sum up: not all driveItems are possible to download, even when they are derived from the same file. Sharable link for the file works, but extracting driveItem from children list of parent folder driveItem fails to work even though they are items for the same file ...
I've entered the @microsoft.graph.downloadUrl into web browser and the file got downloaded.
So it seems the problems is with the function:
file_item.download_session( local_file, print_progress, chunk_size=1024 * 512 ).execute_query()
It operates on thte same driveItem having @microsoft.graph.downloadUrl that is possible to download via url but not using the method.
Using the single file approach:
remote_file.download(local_file).execute_query()
gives the same 400 error:
office365.runtime.client_request_exception.ClientRequestException: ('BadRequest', "Resource not found for the segment '...'.", '400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/shares/...