def get_file_content(access_token, site_id, drive_id, file_id):
headers = {
'Authorization': f'Bearer {access_token}',
'Accept': 'application/json'
}
# URL to fetch the file content
graph_api_url = f'https://graph.microsoft.com/v1.0/sites/{site_id}/drives/{drive_id}/items/{file_id}/content'
response = requests.get(graph_api_url, headers=headers)
if response.status_code == 200:
return response.content
else:
response.raise_for_status()
I have ms word file in this link: https://m365x36241825.sharepoint.com/:w:/s/Contoso/EfdVPx-4F85PoTiVi_vjqD0Bk2qXB_dwapVsC5t600YS-g?e=ejxhi6
which is opening file in ms word
I have a word file in ms word which is on sharepoint and i want to get the content of the file in python using ms graph api.
New contributor
Swasti Ranjan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.