I am trying to get a list of videos from a videos library (site assets library) using REST. Below is my query:

 var url = _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists/getByTitle('Videos')/items";

I have only one video in the list, but in the returned results, it's getting 5 results. Any idea what is wrong with my query, why is SharePoint seeing too many items?

  • IIRC, video libraries make renditions or thumbnails or something like that, if dump the results, what are you seeing? – Eric Alexander Nov 23 '16 at 16:03
  • Hi Eric, thanks for your answer. I am seeing my video first with ID=1, then am seeing other 4 results, with content type = '0x012000593231F03445054285DA2C3431638C53' and all other columns are null. – Brittany Rutherford Nov 23 '16 at 16:06
  • @EricAlexander, it works fine if I use CAML with JSOM, but not with REST. – Brittany Rutherford Nov 23 '16 at 16:06
up vote 1 down vote accepted

Like Eric Alexander said above, SharePoint creates a smattering of other 'helper' content for the videos such as renditions and thumbnail images. If you're only retrieving mp4 files, then you can use ContentType/Name = 'Video'.

If you will be retrieving other video file types (such as .mov or .avi), then you will have to get more creative because those come back as 'Image' content types. At first glance, it looks like SharePoint always uses .png to create thumbnail images, so you could potentially filter out results with content type 'Image' and FileLeafRef or FileRef values ending with '.png'.

Full disclosure: I haven't tested that thoroughly so use at your own risk.

Below is my complete api query:

    [site]/_api/web/lists/GetByTitle('Videos')/items?$select=ContentType/Name,Id,Title,FileLeafRef,FileRef,OData__SourceUrl,VideoSetExternalLink,Created,Created_x0020_Date,AlternateThumbnailUrl,EncodedAbsWebImgUrl,EncodedAbsThumbnailUrl,FileDirRef,LinkFilename&$expand=ContentType

I'm not sure exactly what the answer is, but I'm noticing that each video is a "Document set" of some sort and that in the returned json there are preview images and other items. Document sets are a kind of folder and the have a FileSystemObjectType of 1. The actual videos are not folders and have a type of 0. So at first I thought of $filter=FSObjType eq 0 (for whatever reason the returned property is the spelled out version, but you need to filter on the abbreviated version!). And that would kind of work if you don't have anything else in the asset library, but as soon as I added some images they also aren't folders.

So here is what I worked out

<site>/_api/web/lists/getbytitle('Videos')/items?$filter=ContentType eq 'Video Rendition'&$select=FileLeafRef,FileRef,ContentTypeId,ContentType/Name&$expand=ContentType

I don't actually have multiple renditions for my videos, so I don't know what happens in that case. I don't think SP automatically creates video renditions the same way it can create image renditions. I think that it just allows you to manually manage them.

Also you don't need the FileLeafRef and FileRef in the $select, but I figured you might be wanting to get the url for the videos...

  • Document Sets are Microsoft representation in SharePoint of Folders with (SharePoint)Metadata. They will be "Yellow" Folders when you open them with Windows Explorer (but Explorer can't show you the SharePoint metadata). I have never looked at the Video Portal.. but it sounds logical that Microsoft stores videos in their own Folder (DocumentSet) with the same name. Thus allowing renditions and other (future) assets related to the video be stored in one container (DocumentSet) – Danny '365CSI' Engelman Nov 23 '16 at 17:22
  • @Danny'365CSI'Engelman, it's not the video portal, it's site assets library. – Brittany Rutherford Nov 23 '16 at 19:11
  • @Rothrock, thank you.But what if I want to get images AND videos? if I do "or ContentType eq 'Image' .. it will get images for the video rendition as well. – Brittany Rutherford Nov 23 '16 at 19:22
  • Not clear on what you mean. Do you mean you do want the video thumbnails or you don't want the video thumbnails? – Rothrock Nov 23 '16 at 19:37

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.