Panopto API 203: Looping through more than one page

Return to the Panopto API index page

We’ve shown that Visual Studio can crash when dealing with a few hundred sessions, and your server probably has thousands of videos. We should therefore deal with a few videos at a time and loop through them.

By adjusting the standard code on page 100 we can set variables for the pagination and do a quick sum to check if we are at the end

We set a few variables, the first ensures that the while loop at the end continues until we flag that we are on the last page

We then use our standard code for searching and pagination, but using our resultsPerPage and page variables instead of hard coding them.

This is our calculation to find if we are on the last page. For example

5 results per page * (0 + 1) >= 5000 results // FALSE

5 results per page * (999 + 1) >= 5000 results // TRUE, you are on the last page

Remember that page starts at 0, but needs to be 1 when doing math, hence the (page + 1)

I can now use the code from 201 again

Finally we need to increment page by 1 ready for the next loop

Full code

Return to the Panopto API index page

One Comment

  1. Manjith Gunatilaka

    Hi

    Can we get a sample Python code how to use Soap web service for the ListUser method in UserManagement WSDL.

    Thanks

    8 months ago

Leave a Reply

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