Panopto API 001: Connecting to the server

Return to the Panopto API index page

In this first example we’re going to connect to the Panopto server using a username and password.

Firstly you will need to connect to your Panopto server and add a new user. In this example I used the username “api” and the password “s2ezupajePhasaP5

The Panopto create user screen from Settings > Users

Once the user exists you will need to give it some permissions. You should give the user only the permissions it needs. If you are using a development server then I’d recommend making it an administrator when following these instructions.

Click settings and set the role to administrator

Click settings under the API user to change its permissions

You’ll find these settings under “Roles”

We now have a user that can connect to the server. Horray!

Open Visual Studio and create a new Command Line C# application

If you’d like to copy and paste my example code I recommend calling your application

If everything has gone to plan you should have some code like this

This is all fine, but the reason to use C# is that it knows all the possible commands that Panopto accepts. So we need to add the services to our application.

Right click on ConsolePanoptoAPI (or your application name) and select Add Service Reference

Add a service reference

A screen will pop up asking you for an address. You’ll need to enter the following

https://[your panopto server here]/Panopto/PublicAPI/4.2/Auth.svc?wsdl

For example, if your server is panopto.university.ac.uk then put https://panopto.university.ac.uk/Panopto/PublicAPI/4.2/Auth.svc?wsdl into the address box. Press Go

Add your server then press go

Some services should appear in the box. Before you finish type

into the Namespace box

The namespace that will be used in the project

If everything has worked correctly you’ll see PanoptoAuth in the solution explorer

Panopto Auth is under Service References

We can now use this simple service reference. Put this code between the curly brackets of static void Main(string[] args) {}

These are the log in details we made earlier. You’ll need this sessionAuthInfo within all the other commands we make

We could carry on writing PanoptoAuth. in front of our commands, but we can write

At the top of the console application to tell visual studio to expect commands from that namespace.

You may have noticed when adding the service reference that Auth has a very small amount of commands within it (which is why I’ve used it first). One of those commands is GetServerVersion and we can use it now.

Add the following code after the }; of PanoptoAuth.AuthenticationInfo

Lets start at the bottom and work up.

Console.ReadLine()
This makes the command prompt window wait for you to type something in. It simply makes it so that the window doesn’t close a few milliseconds after you run your program.

Console.WriteLine(iAuth.GetServerVersion());
Console.WriteLine outputs whatever is within the brackets

iAuth.GetServerVersion()
So how did I know that this command existed? Well if you double click on PanoptoAuth in the Solutions Explorer you’ll see the commands that are available. You’ll also notice that GetServerVersion is under IAuth.

The object browser shows all the functions available

IAuth iAuth = new AuthClient();
Finally the structure above tells which object we need to make and the class of the object.

Finally we run the program and get our output

The output after running our program

Our code now looks like this

References

Official documentation for IAuth | AuthenticationInfo | GetServerVersion

Return to the Panopto API index page

2 Comments

  1. Graham

    You may have noticed that we define the sessionAuthInfo, but don’t actually use it in our GetServerVersion() command. This is because GetServerVersion doesn’t need authentication.

    Despite this I like the code because
    a) AuthenticationInfo is something you’ll need in all your code
    b) The simple string it returns is the closest thing to a “Hello World”

    What you should be aware of is that the API hasn’t actually checked your username and password works yet.

    4 years ago
  2. Roger Cantillo

    Hi Graham, any chance the API has been extended to support REST?

    2 years ago

Leave a Reply

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