-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Category
- Bug
Describe the bug
I'm trying to use the SharePoint REST API v2.0 endpoint and especially the https://mytenant.sharepoint.com/sites/dev/_api/v2.0/sites/{siteId}/lists/{listId}/items/{itemId}/preview method to get the preview URL for a document in a SharePoint site from an SPFx Web Part just like the Microsoft Graph counterpart (HTTP POST). I'm following the documentation available here.
When using the url ../driveItem/preview and the SPHttpClient SPFx builtin class, the call returns a HTTP 403 error every time even if I have access to the underlying item.
However, using the exact same url but this time with AadHttpClient works well (HTTP 200). Here is an illustration of the issue:
I precise I didn't grant any specific permissions in my SPFx package-solution.json. Not sure if this is expected since the authentication method is different between the two approaches (Bearer token vs cookie/digest).
Last but not least, the similar call ../driveItem/thumbnails for the same item (HTTP GET) using SPHttpClient works well.
Steps to reproduce
- In a SPFx Web Part, make a call to
https://mytenant.sharepoint.com/sites/dev/_api/v2.0/sites/{siteId}/lists/{listId}/items/{itemId}/previewURL usingSPHttpClient. - Make the same call with
AadHttpClientto see the difference.
Expected behavior
Using /_api/v2.0/sites/{siteId}/lists/{listId}/items/{itemId}/preview endpoint using SPHttpClient should returns an HTTP 200 when user has access to the element.
Developer environment
- SPFx 1.10.0
- Office 365 Developer tenant (not first release)
