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
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
Did anyone manage to find a workaround for this? The Rest API endpoint returns a different result compared to the graph API
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?
WarrenBelz
146,651
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional