Three Simple Methods to Invoke the Vidispine API From .NET Code

Binagora is on fire and returns with another guest post. We know we have a bunch of developers on .NET, therefore we created a .NET SDK. This post shows how you can invoke the Vidispine API from .NET, using the SDK or using standard .NET classes. All with example code.

The following article describe three simple ways to invoke the Vidispine API from .NET code. Two of them use standard .NET classes, while the last one uses the Vidispine .NET SDK. Code snippets were written using C# but you can of course use another language, such as VB.NET, if you want to.

We’ll use the simplest test case possible, and let us retrieve the id of the first available item in the Vidispine library.

First of all, let’s see how it’s done in Postman. As you may already know, it’s just a simple http GET request to the Vidispine API to retrieve an item id.

Retrieve item id from Vidispine API using Postman

Notice that we’re using two Postman variables for a specific environment:

  • {{vs}}: this is the Vidispine base address (url + port)
  • {{credentials}}: this is the username and password in basic http format (:) encoded in base64.

Environment variables when using Vidispine API with Postman

Ok, that was the principle of how to query the Vidispine API for an item id. Now let’s do the same thing from code.

Given the following constants:

Option 1: Using WebRequest class

Create a WebRequest, set the credentials and execute the request. Remember to release the request calling the Dispose() method or wrapping the instance into a using statement as we did in the sample.

Notice that in this case, we know the response contains a plain text with an item id. That’s why we read the stream, and converts it into a string instead of a specific type.

Option 2: Using HttpClient class

Similar to previous option, it is just a matter of using another http client from the .NET framework.

In this case, credentials are specified on a client handler, then the http client is created using that handler.

The request is executed asynchronously, which is powerful and could be needed in a real situation.
In this case we’re just reading the Result property immediately, but it’s important to understand that the request is fired in an independent thread. Once thread is completed, you can execute your own callback.

Option 3: Using Vidispine .NET SDK

Finally the easiest way to do it, just call the SDK. Notice that in this case, the action to be executed is not part of the address. You specify the object and action based on the properties. We may say this is the strongly typed option to do it.

You can find more information about how to download and use the Vidispine .NET SDK in the post Getting Started With the Vidispine .NET SDK. If you want to try out the SDK, you can find the latest versions of the SDK here:

Running the app will show you the result 3 times, once for each option. In this case first item available is #525 but of course that will depend on your environment.

Result from running the .NET app against Vidispine API

You can download the full console app code from the following GitHub Gist.

Hope you like it.

Binagora Logo - smallThis blog post was written by our friends at Binagora. Check them out and see how they can help you with your next Media&Entertainment project.