1

I am trying to create a sharedURL via a picker in my app that constucts a web url with a query par linked to a sharepoint file, which reads into the app on load. For some reason if I grab the manual sharedURL from sharepoint it works, as I endode it and point to:

const url = https://graph.microsoft.com/v1.0/shares/u!${encodedString}/driveItem;

With auth and grabbing the @microsoft.graph.downloadUrl I can easily read into memory and into my app. so all good!

However I cannnot get the createLink from graph api to work as it does not include the ?e= query par, like a manual share option does. It would be good to know what it represents as I cannot access the content without it.

const createLink = https://graph.microsoft.com/v1.0/drives/${driveId}/items/${itemId}/createLink;

I get back a successful 200 or 201 on POST the create the link and has the same weburl but without ?e= so am thinking that is the issue. but when I read it in, it says Requested sharing link could not be found.

Could someone please advise pls?

1
  • btw this is connecting to organisations, so could be a permissions issue but ive added Files.ReadWrite, Files.ReadWrite.All, Sites.ReadWrite.All to Azure and my auth login request
    – JasonC
    Jan 18 at 17:13
0

The ?e= query par doesn't affect anything. If you grab the manual sharedURL from sharepoint and remove the ?e= query par from the link, it would still work for you.

For your issue, after you creating the share link, please try to access this item in the browser with the createLink.

Then use graph api to access this createLink, check if it works for you.

Update:

Yes, it's the permerssion issues. When you select file from your onedrive, you already have access to the file. So you could read the file with the createlink. However, when creating the kink on orgainsation level, your permission is not granted. So you can not read the file. After you visiting the link via browser, your permission is automatically granted. Then you can read the file with the createlink. Also you could grant permission on the link through the graph api:https://docs.microsoft.com/en-us/graph/api/permission-grant?view=graph-rest-1.0&tabs=http

4
  • Thanks for replying, ive been testing it today. If I select a file from my personal drive the createlink works and I can read the file, on orgainsation level I can create the link but cannot read the file. Do I need to look at permissions or roles when creating the link to determine who can access it ? both links work when visting via the broswer
    – JasonC
    Jan 19 at 12:18
  • something similar to this, docs.microsoft.com/en-us/graph/api/…. Am I on the right path?
    – JasonC
    Jan 19 at 12:20
  • Yes, you are right. That's the permisson issues. You could check my updated answers. Jan 20 at 2:31
  • Thanks for the updated answer. I am getting to understand the permissions abit better now but still cannot get the create a link to work on org level. docs.microsoft.com/en-us/graph/api/… does not work on an org level only personal or via a manual shared link. This is getting the weburl from the createllink post (encoding it ) the request that endpoint to grant permissions, on an org level I get sharing ID is not found, even tho my encoding is workly correctly on my personal and any manual sharing links from SharePoin. ill post code
    – JasonC
    Jan 21 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.