Panopto API 102: Getting a particular folder

Return to the Panopto API index page

We’re going to build on the code we wrote in 101. If you don’t have it already, grab the starting code from page 100 and paste in the following

We now have a program that lists the first 5 folders on your Panopto server. However we can be more precise and search for a folder.

The documentation says the third parameter of GetFoldersList is a search field

Highlighted is GetFoldersList and the third parameter.

Currently it’s null (that means literally nothing) so we get everything* back, but we can put a search term in there. (* the example code only returns top level folders, so it isn’t everything but we aren’t filtering by search term)

Under // START WRITING CODE HERE write

You should pick a folder that already exists. You should also confirm that you can search for the folder name directly on your Panopto server.

Next change the ListFoldersResponse response… line to read

If you run the application again, it should return the folder in question. It is still using the pagination function, so if your search would have returned more than 5 results, only the first five will be returned

I used a very specific search term, so only had one result back

But what if I wanted to find something specific, that returns multiple results? For example I’ve made a folder called “test”, but when I search for “test” it returns all these…

(Note: For this query I have changed MaxNumberResults to 100)

The one I want is at the bottom

In this case I would change MaxNumberResults to 1, to ensure I only get one result, and add SortBy to equal Relevance (SortBy = FolderSortField.Relevance)

I now get my folder, as I’m now sorting by relevance and getting a single result back

Just the one result from our search by relevance

Which leads us up to the most useful thing we’ll do on this page, finding a folder ID and external folder ID from a name

Full code below

Return to the Panopto API index page

One Comment

  1. Graham

    The code to check for a user is very ineffective at present. I should have used

    http://support.panopto.com/pages/PanoptoApiHelp/html/aa0bc5c5-e518-2fe4-d390-651f1ab36c2f.htm

    GetUserByKey, which brings back user details based on their username. I’ll hopefully update this code at some point.

    5 years ago

Leave a Reply

Your email address will not be published. Required fields are marked *