1
votes

I am new to SPFX framework and MSGraph API.

My requirement is to display items trending around me and hence used the API (https://graph.microsoft.com/beta/me/insights/trending). In the response, PreviewImageURL is displayed (which is onedrive API).

I am trying to bind the url to img tag but getting broken image. How to display PreviewImageURL?

1

1 Answers

0
votes

Being a beta endpoint, it can be tricky but based on what I'm seeing in Graph Explorer (see here), the previewImageUrl is a call into the SharePoint REST API.

The prototype for these URLs looks like https://{tenant}.sharepoint.com/_api/v2.0/drives/{drive-id}/items/{item-id}/thumbnails/0/small/thumbnailContent. In other words, this URL represents a call into the SharePoint API rather than a URL to the image itself.

As best I can tell, there is no way to get at this through Graph at the moment. You should however be able to make a second REST call to the previewImageUrl to grab the object. Keep in mind this will require that you request additional scopes during authorization to cover the SharePoint API as well.