Hi You may retrieve files from SharePoint in two different ways.
- Through the site, provide the site ID and then get the list of items in the root
https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root/children
- Sharepoint files are also stored in the drive. So you can access them by drive.
For example, the curl below will return the file as a stream
https://graph.microsoft.com/v1.0/drives/{drive-id}/items/{driveItem-id}/content
Example in Python via Graph SDK
import asyncio from azure.identity import DeviceCodeCredential
from msgraph import GraphServiceClient
credential = DeviceCodeCredential(
tenant_id='tenant id',
client_id='client id',
client_secret='client secret'
)
scopes= ['https://graph.microsoft.com/.default']
client = GraphServiceClient(credentials=credential, scopes=scopes)
async def get_drive_item():
item = await client.drives.by_drive_id('drive id').items.by_drive_item_id('item id').content.get()
if item:
with open("my_file.xlsx", "wb") as binary_file:
# Write bytes to file
binary_file.write(item)
asyncio.run(get_drive_item())