Yes, it should be a POST request rather than a GET request, because it allows you to send the request body.
By the way, the preview action is currently only available on SharePoint and OneDrive for Business, not personal OneDrive.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I have created an App registration.
Endpoint in question: https://learn.microsoft.com/en-us/graph/api/driveitem-preview?view=graph-rest-1.0
According to that document, this endpoint requires at least "Files.Read" permission. I've requested all of these: "Files.Read.All", "Files.ReadWrite", "Files.ReadWrite.All", "Sites.Read.All", "Sites.ReadWrite.All"
After acquiring the access token, I then call the preview endpoint, like so:
https://graph.microsoft.com/v1.0/drives/{DRIVE_ID}/items/{ITEM_ID}/preview
And receive back the error
{"error":{"code":"notAllowed","message":"Operation not allowed"}}
I have tried to preview a PNG, TXT, PDF, XLSX and CSV files.
What Am I doing wrong?
Thanks!
Yes, it should be a POST request rather than a GET request, because it allows you to send the request body.
By the way, the preview action is currently only available on SharePoint and OneDrive for Business, not personal OneDrive.
Ah wait wait wait ... it needs a POST request, not a GET ... i've been sending GET ... I receive this now as mentioned in the docs:
{
"getUrl": "https://www.onedrive.com/embed?foo=bar&bar=baz",
"postParameters": "param1=value¶m2=another%20value",
"postUrl": "https://www.onedrive.com/embed_by_post"
}