Get video thumbnails from SharePoint using Microsoft Graph
SharePoint Online has a service to generate and return links to media thumbnails stored in the libraries, It works great for a lot of formats but mp4 videos are no longer supported.
This article describes an alternative process to retrieve the thumbnails for the videos you have stored in the libraries using Microsoft Graph.
Nowadays everything is available through Microsoft Graph and with a few queries you will be able to get 3 resolutions for the video thumbnail.
All the steps described below can be accomplished on Microsoft Graph Explorer and then reused with your preferred development language making the appropriate rest calls.
In order to get the thumbnail, you will need to get first:
- The ID of the site where the videos is stored
- The ID of the drive (library) where the video is stored
- The ID of the video
Get the Site ID
To get the ID of the site you can do the following request, more information about it can be found here.
Example: Since we only need the ID it can be specified in the query string
Get the Drive ID
Now that you got the ID for the site you need to get the ID for the library, doing the following request, more information about it can be found here
Example:In this example I’m requesting the ID and the name of the library in case it’s needed to iterate through them
Get the Video ID
Once you get all the ids you need, you need to list all the elements inside the library doing the following request, more information about it can be found here
Example: In this example I’m listing all the files in the library root folder and listing the ID and the name of the file.
Get the thumbnail
Once you get the 3 main IDs you just need to request the preview thumbnail for the file using the following request, more information about it can be found here
Example:You will get a JSON object with 3 resolutions for the video thumbnail