Panopto API 202: Working with user details and session details

Return to the Panopto API index page

This page was based on the query from the Panopto Forum. Sometimes it is best to try and something from the real world.

We’ve been trying to promote the use of Panopto for student presentations, but keep getting the same feedback from academic staff. If they use the dropbox facility then each student has to log in to the recorder separately, and this adds time to an already busy session. However, if the academic records all the presentations logged in as him/herself then the recordings will be available to all students, and access then has to be managed individually. It would therefore help matters if the academic could move the recording into the dropbox folder and then change the owner of the recording to the individual student, thereby having the same end result as the student having logged in to record.

This request seems to have a few requirements

  1. We need to deal with sessions in a particular folder
  2. We need to change the owner of the video in a programmatic way

Just these two requirements tell us that were’re going to be using more than one of our service references. Sessions in a folder are managed by the PanoptoSessionManagment, and actually changing the owner is also PanoptoSessionManagement, but getting the user details used to change the owner is PanoptoUserManagement.

We can’t use the same authentication information for both, so we’ll need to make two.

Object names need to be unique, so you’ll notice that I now need to refer to sessionAuthInfoPSM or sessionAuthInfoPUM when referring to session and user management.

For this request I’ve decided that the easiest way to choose a user is for the academic in question to put the username of the student as the first word of the presentation title. This seems the quickest way of using the API to change all the owner details.

To start with we need to do exactly the same as we did on 201, but we do need to change the code to reflect the PSM we added above.

We know that we’ll need to deal with user details as well as session details, so replace // User management goes here with

userMgr can now be used for all these commands.

The end goal for this application will be to call UpdateSessionOwner. Notice how this command states that it must be run by an administrator, so is unlikely to work using the lecturers integration account. It will work for us as long as our API user is an administrator.

UpdateSessionOwner needs to have authentication details, a GUID of a session (or sessions) to update, and the username to change the owner to. We’ve checked the authentication and already found the ID, so we just need to find the username.

The following code, to be added under the “Console.WriteLine(session.Id + “: ” + session.Name);” line takes the first word of the session title, which will hopefully be a username.

As explained in 004, users using Blackboard (or other integrations) have the integration name prefixed to the username. To account for this add this line above the “if (response.Results…” line

We can now refer to the real username

We’re next going to check that the string returned is a real username. We’ll do this by searching for it

You’ll notice that this code is practically the same as further up the page except …

PanoptoSessionManagement is PanoptoUserManagement
ListSessionsRequest is  ListUsersRequest
ListSessionsResponse is ListUsersResponse
sessionMgr is userMgr
GetSessionsList is ListUsers

… so very similar.

Because it is so similar we can use almost the same code to loop through the result.

The main difference here is that we have userReponse.PagedResults instead of [session]response.Results. I’ve also added a check to see if the username matches what we are expecting, in case the first word is “a” and the first result is “andy” (i.e. the user doesn’t exist).

We can now update the owner, but UpdateSessionOwner needs an array of sessions, so we need to make our session an array before running the main command

Full code below

Return to the Panopto API index page

2 Comments

  1. Sihan

    Hi,
    Appreciate if you can get back to us on following with api and operations details.

    1. How can we get a list of userID’s by using session ID?

    2. How to differentiate between live and recorded sessions using userID?

    Thanks,
    Sihan.

    8 months ago
  2. Ajit Narkhede

    Hi,
    Appreciate if you can get back to us on following with api and operations details.

    1. How can we get a list of userID’s by using session ID?

    2. How to differentiate between live and recorded sessions using userID?

    Thanks,
    Ajit

    8 months ago

Leave a Reply

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