0
votes

Our web app allows storing links to OneDrive/SharePoint drive documents.

These links are obtained with OneDrive File Picker UI, webUrl field, look like this eg:

https://company.sharepoint.com/sites/devops2/Shared%20Documents/Company%20Cases/A12345%20-%20case%20name%20-%20RENAMED/case-report.pdf

or

https://company-my.sharepoint.com/personal/user_company_onmicrosoft_com/_layouts/15/Doc.aspx?sourcedoc=%7BC52518FD-05B8-428C-BAE7-A3469890493D%7D&file=%D0%9A%D0%BD%D0%B8%D0%B3%D0%B0.xlsx&action=default&mobileredirect=true

Is it possible to somehow turn this link into drive-id and item-id (driveItem) for further processing with MS Graph API? (web app has all the tokens/consents already)

1

1 Answers

3
votes

Here's the answer:

https://docs.microsoft.com/en-us/graph/api/shares-get?view=graph-rest-1.0&tabs=javascript

  1. "Encoding sharing URLs" section (pass webUrl from OneDrive File Picker)

  2. GET request with this encoded string to /shares/{encodedUrl}/driveItem