
Three Simple Methods to Invoke the Vidispine API From .NET Code by Vidispine June 15, 2016 Howto
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.
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.
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:
C#
private const string address = http://xxx.xxx.xxx.xxx:8080/API; private const string userName = admin; private const string password = admin;
1
2
3
private const string address = http://xxx.xxx.xxx.xxx:8080/API;
private const string userName = admin;
private const string password = admin;
Option 1: Using WebRequest class
C#
private static string GetUsingWebRequest(string requestUri) { var request = (HttpWebRequest)WebRequest.Create(requestUri); request.Credentials = new NetworkCredential(userName, password); using(var response = (HttpWebResponse)request.GetResponse()) { var stream = response.GetResponseStream(); var reader = new StreamReader(stream); string result = reader.ReadToEnd(); return result; } }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
private static string GetUsingWebRequest(string requestUri)
{
var request = (HttpWebRequest)WebRequest.Create(requestUri);
request.Credentials = new NetworkCredential(userName, password);
using(var response = (HttpWebResponse)request.GetResponse())
{
var stream = response.GetResponseStream();
var reader = new StreamReader(stream);
string result = reader.ReadToEnd();
return result;
}
}
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
C#
private static string GetUsingHttpClient(string requestUri) { var handler = new HttpClientHandler() { Credentials = new NetworkCredential(userName, password) }; var client = new HttpClient(handler); client.BaseAddress = new Uri(address); string message = client.GetStringAsync(requestUri).Result; return message; }
1
2
3
4
5
6
7
8
9
10
11
12
13
private static string GetUsingHttpClient(string requestUri)
{
var handler = new HttpClientHandler()
{
Credentials = new NetworkCredential(userName, password)
};
var client = new HttpClient(handler);
client.BaseAddress = new Uri(address);
string message = client.GetStringAsync(requestUri).Result;
return message;
}
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
C#
private static string GetUsingVidispineSdk() { var rootResource = new VidispineResource(address).Authenticate(userName, password); var itemResource = rootResource.Item; string result = itemResource.SearchPlainGET.Number(1).CallText(); return result; }
1
2
3
4
5
6
7
8
private static string GetUsingVidispineSdk()
{
var rootResource = new VidispineResource(address).Authenticate(userName, password);
var itemResource = rootResource.Item;
string result = itemResource.SearchPlainGET.Number(1).CallText();
return result;
}
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:
64-bit version of the Vidispine .NET SDK v4.5
32-bit version of the Vidispine .NET SDK v4.5
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.
You can download the full console app code from the following GitHub Gist.
Hope you like it.
This 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.
Most recent headlines
06/10/2025
France T l visions, France's leading broadcaster, has received the 2025 EBU ...
04/09/2025
Monumental Sports & Entertainment (MSE), in collaboration with Dalet, has been a...
04/07/2025
By Lucy Spicer
Editor's note: We are deeply saddened by the passing of Robe...
04/07/2025
The Summer Reading Challenge has inspired children across the U.K. to embrace a ...
04/07/2025
Introducing CVP Auctions: Trusted Tech, At Auction-Only Prices
Brie Clayton July 4, 2025
0 Comments
A New Destination for Film and Broadcast Gear at U...
04/07/2025
Unveiling China's Ecological Wonders with URSA Mini Pro 12K
Brie Clayton July 4, 2025
0 Comments
Nature Documentaries Freeze Epic Momentsin Extrem...
04/07/2025
Create Any Planet in After Effects
Graham Quince July 4, 2025
0 Comments
The Advanced 3D renderer in After Effects makes it really easy to import 3D o...
04/07/2025
Custom Gradient Colorize for Resolve Fusion
Simon Ubsdell July 4, 2025
0 Comments
Digging into the theory of the gradient colorize process to build ou...
04/07/2025
Watching live sports on TV these days is a delicate balance for broadcasters how much information is too much?...
04/07/2025
WASHINGTON As Federal Communications Commission Chair Brendan Carr works to achieve his goal of a very busy, productive summer at the FCC, the agency has rele...
04/07/2025
Other World Computing Launches OWC Guardian USB-C Hardware-Encrypted Portable SS...
04/07/2025
CANAL Brings MotoGP to Vision Pro with Blackmagic URSA Cine Immersive
Brie Clayton July 3, 2025
0 Comments
Experience MotoGP like never before as CA...
04/07/2025
Friday 4 July 2025
Watch the trailer here https://youtu.be/Od5WpvWmDr8
Further...
04/07/2025
The Pitch comes to RT Radio 1 airwaves this Sunday at 7pm. The Pitch is a brand...
03/07/2025
For our Vario-Jib, as well as for a repertoire of weights, we now have carts that make transport easier...
03/07/2025
One of our latest innovations: Slider Drive Unit!
Our Vario Slider not only comes with improvements and new features, but also with its own drive unit!
Our i...
03/07/2025
The 360 EVO lives up to its name: 360-degree rotation not only on the pan axis, but also on the roll axis, enables filmmakers to take their creative visions eve...
03/07/2025
What a buzzing few days at BSCExpo in London!
We were thrilled to connect with so many talented professionals from the world of cinematography.
A huge thank ...
03/07/2025
ADOLESCENCE - Shot with Panther Tower"The whole rig had to be detachable mid-episode
Netflix limited drama series Adolescence has been gaining attentio...
03/07/2025
To achieve a true level of decisive overmatch, communication systems must be as ...
03/07/2025
The Broadcasters Foundation of America has named Ray Hopkins, president of U.S. distribution at Paramount Global, to its board of directors....
03/07/2025
SIOUX FALLS, S.D. In his first major policy speech, Federal Communications Commission chair Brendan Carr outlined his Build America Agenda for the agency'...
03/07/2025
As the industry is making a major push to transition to NextGen TV and develop new businesses that will fund the next generation of broadcasting, TV Tech's ...
03/07/2025
Despite enabling its subscribers to watch films and TV shows in the highest possible resolution, Netflix has revealed it is taking things old school with the in...
03/07/2025
WASHINGTON In response to news that Paramount Global has agreed to pay $16 million to settle a lawsuit by President Donald Trump, Democrats and other administra...
03/07/2025
WUPPERTAL, Germany Riedel Communications today launched RefSuite for professional sports workflows....
03/07/2025
WEITERSTADT, Germany LYNX Technik, a provider of modular signal processing solutions, has announced that founder and longtime CEO Winfried Deckelmann is steppin...
03/07/2025
WASHINGTON Representatives from six trade groups representing tech, pay TV, broadband, LPTV and other sectors recently met with Federal Communications Commissio...
03/07/2025
PLYMOUTH, Wis. Dan Whealy has acquired Heartland Video Systems and will be its new owner and president, the systems integrator said....
03/07/2025
Acclaimed filmmaker, educator, and industry veteran Jay Holben has released his most ambitious work to date: The Director's Guide to Everything a sweeping...
03/07/2025
For Los Angeles-based photographer Scout Pruski, documenting the annual Dyke Day LA is a way to honor and give back to the city's legacy queer community and...
03/07/2025
Modular, Travel-Ready Solution Matthews Studio Equipment launches the new Chimera V-Flat Panel Frame Kit, the lightweight and modular, ultra-durable alternativ...
03/07/2025
Dalet, a leading technology and service provider for media-rich organizations, today announced the release of Dalet Flex 2025.6 LTS (long-term support), introdu...
03/07/2025
Lightware's LARA Wizard makes it quicker and easier than ever to set up audio-visual (AV) room automation and control configurations, ensuring anyone, from ...
03/07/2025
Alfalite, the only European manufacturer of LED screens, has obtained both the NCAGE Code (NATO Commercial and Government Entity) and TAA (Trade Agreements Act)...
03/07/2025
nxtedition is implementing a new solution for WIN Network, based in its headquarters in Wollongong, New South Wales, Australia. The nxtedition integrated platfo...
03/07/2025
ORS Group and Insys Video Technologies today announce the launch of a new joint brand identity: Big Blue Marble. The move reflects the evolution of a long-stand...
03/07/2025
Evergent, a global leader in customer lifecycle management and monetization solutions for subscription-based businesses, today announced the successful results ...
03/07/2025
LYNX Technik, provider of modular signal processing solutions today announces an executive leadership transition, effective July 1, 2025. Markus Motzko has been...
03/07/2025
Chaos Releases V-Ray for Blender
Brie Clayton July 2, 2025
0 Comments
Production-Proven Renderer V-Ray Arrives Natively in Blender for the First Time;...
03/07/2025
Calvin University Adds Blackmagic Replay to Broadcasts and Streams
Brie Clayton July 2, 2025
0 Comments
Replay workflow joins 14 Blackmagic Design cam...
03/07/2025
Berklee's Gospel Performance Program Welcomes Jonathan Nelson as the Herb Al...
03/07/2025
Back to All News
Get Ready for Even More Action! Netflix Has Confirmed the Thir...
03/07/2025
Back to All News
Get ready for even more action! Netflix has confirmed the thir...
03/07/2025
In today's fragmented media landscape, advertisers expect more than just reach - they want seamless cross-platform campaigns that deliver measurable results...
03/07/2025
** MEDIA ALERT ** Shonen Jump Store Hosting Los Angeles Pop-up During Anime Exp...
03/07/2025
Thursday 3 July 2025
David Harewood and Matthew Broome in Mozart: Genius for Hi...
03/07/2025
The Sky WNT Fund supports Womens National Team players with a 30,000 bursaryThursday 3 July 2025
Sky Ireland has announced the four recipients of the 2025 Sky...
03/07/2025
The forecast this month is showing a 100% chance of epic gaming. Catch the scorching lineup of 20 titles coming to the cloud, which gamers can play whether indo...
02/07/2025
Hege Wik and Odin appear in FOLKTALES by Heidi Ewing and Rachel Grady, an official selection of the 2025 Sundance Film Festival. Courtesy of Sundance Institut...