Forum Discussion
Getting the content (links and embedded object from Pages in Notebook on Sharepoint )
- aymieeDec 27, 2023Brass Contributor
@Kidd_lp
I have set Read/Write/Full permission for Sites and Teams and Notebook. I can even copy the link and open it up in a browser. I just get a 401 when using request.get(url, token).
I had to go through a long process of using the graph api to test if I can get the content:
await client.drives.by_drive_id('drive-id').items.by_drive_item_id("drive-item-id").content.get()
but this is not desireable as I have the URL via the original call to client.sites.by_site_id(site_id).onenote.pages
Apparently the url I have is the Sharepoint sharing URL meant for use in a browser.
'https://domain.sharepoint.com/:w:/s/it/blahblahblah' Was hoping for a way to map this link to the drive item ID.
Edit: In case anyone has the same issue:
I was able to get the file name and retrieve the content from the "OneNote Uploads" folder:file_path = f'/{folder_name}/{file_name}'url = f'https://graph.microsoft.com/v1.0/sites/{site_id}/drive/root:/{file_path}:/content'
Thank you.