web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Why does the sharepoin...
Power Automate
Unanswered

Why does the sharepoint REST API return a different link than the one returned by the Graph API?

(0) ShareShare
ReportReport
Posted on by 66

I am trying to standardize Graph API with Sharepoint REST API v2.0 since the Graph explorer validates using "whatif" that the request I make can be called from Sharepoint API, but both links are totally different

 

A little context, I am trying to generate an embedded link, the Graph API generates it well and it is viewable as editable, but in Sharepoint API, although it generates the link, this message appears when I open it in the browser

 

RequestAccess.png

 

In the Graph API I use this url with the POST method and their respective headers

https://graph.microsoft.com/v1.0/sites/{siteId}/drives/{driveId}/items/{fileId}/preview

{
 "allowEdit":false,
 "viewer":"office"
}

And in Sharepoint I use the same but with this url

https://{tenantName}.sharepoint.com/{relativeUrl}/_api/v2.0/drives/{driveId}/items/{fileId}/preview

What Graph API returns is this

https://{tenantName}.sharepoint.com/sites/{relativeUrl/_layouts/15/embed.aspx?uniqueId={uniqueFileId}&access_token={token}

But Sharepoint API this

https://{tenantName}.sharepoint.com/sites/{relativeUrl}/_layouts/15/PreAuth.aspx?sourcedoc={uniqueFileId}&action=embedview#access_token={token}

Although in Graph explorer it tells me that I must leave "oneDrive.preview" at the end but in both cases it generates the link

 

The strange thing is that in Sharepoint API it returns the route with this preAuth and an access token shorter than the one returned by Graph API and I think that is why it does not show the link, a clarification, I have full access to the Sharepoint site and that the Sharepoint API link tells me that I have to request access, it is absurd, does anyone know how to fix this problem?

 

By the way, the link generated by Sharepoint API has an access time of 5 minutes, is there a way to increase that time?

 

Additionally, this link helps me to be able to view/edit within a PowerApp using a code component that uses an iFrame, it is a client requirement for the PowerApp

Categories:
I have the same question (0)
  • MasterRA Profile Picture
    66 on at

    Playing a little with the Sharepoint API, I found the solution to return the view-only url, it turns out that in the body property "viewer" you had to leave "onedrive" to be able to only view the document, while in Graph you can leave it "office" in that property when the "allowEdit" property is set to true or false, but if it is false in the Sharepoint API, if it is required to use "onedrive" to only view the document; The bad thing is that if you leave "allowEdit" in true and the "viewer" in "office", the url does not work, it asks for authorization, so I don't know what I'm doing wrong or why Sharepoint doesn't do the same thing as Graph since it is approved?

  • Roaby Profile Picture
    2 on at

    Did anyone manage to find a workaround for this? The Rest API endpoint returns a different result compared to the graph API

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 464

#2
Haque Profile Picture

Haque 431

#3
David_MA Profile Picture

David_MA 323 Super User 2026 Season 1

Last 30 days Overall leaderboard