ree Simple Meods to Invoke the Vidispine API From .NET Code
15/06/2016
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.
LINK: | http://howto.vidispine.com/insight/three-simple-methods-to-invoke-the-... |
See more stories from vidispine |
Most recent headlines
04/08/2024
Dalet Appoints Santiago Solanas as CEO to Lead Next Era of Growth and Innovation
Dalet, a leading technology and service provider for media-rich organizations, is excited to announce Santiago Solanas as its new Chief Executive Officer (CEO)....
03/06/2024
Dalet and Veritone Reach Agreement to Distribute, Transact and Monetize Media Archives
Dalet, a leading technology and service provider for media-rich organizations, a...
02/05/2024
Reality Slips Away in the Eerie I Saw the TV Glow
PARK CITY, UTAH - JANUARY 18: Jane Schoenbrun introduces the 2024 Sundance Film Festival I Saw the TV Glow premiere at the Library Center Theatre in Park City...
02/05/2024
Meet the 10 Hampton University Students Receiving Spotify NextGen's Scholarship
Spotify is committed to amplifying the voices of underrepresented groups, and th...
02/05/2024
Advertisers and Creators Come Together at Our First-Ever Spotify Sparks in London
With more than 600 million users around the world tuned in to Spotify, there'...
02/05/2024
Gear up for the 2024 Cycling Grand Tours on Australia's Home of Cycling, SBS
Gear up for the 2024 Cycling Grand Tours on Australia's Home of Cycling, SBS Media releases All of the rivalry begins with the Giro d'Italia this we...
02/05/2024
New SBS documentary dives into one of Australia's greatest underdog stories of all time!
New SBS documentary dives into one of Australia's greatest underdog stories ...
02/05/2024
Alone Australia cements its place as one of Australia's biggest hits of 2024
Alone Australia cements its place as one of Australia's biggest hits of 2024 2 May, 2024 Media releases Alone Australia has cemented its place as one o...
02/05/2024
The Making of All of Us Strangers
I always like to base my lighting choices in reality, says cinematographer Jamie D. Ramsay, SASC. For his recent collaboration with writer-director Andrew Haig...
02/05/2024
Hiltron Introduces Field-Upgradable Motorisation Kit for CPI 2385 Satcom Antenna
Accompanying image shows Hiltron's new HMAM-based field-upgradable motorisation kit for the CPI 2385 satellite communications antenna. Backnang, Germany,...
02/05/2024
Millennium Space Systems Selects L3Harris to Build Space Development Agency Electro-Optical Infrared Payloads
MELBOURNE, Fla., May 2, 2024 - L3Harris Technologies (NYSE:LHX) has received a c...
02/05/2024
Samba TV Launches New Generative AI Ad Solution
NEW YORK Samba TV is debuting new capabilities for Samba AI, the company's suite of generative AI technologies. Samba AI's new capabilities provide a re...
02/05/2024
Television Academy Foundation Names Anne Vasquez Executive Director
LOS ANGELES The Television Academy Foundation has announced the appointment of Anne Vasquez as its executive director effective May 13....
02/05/2024
SAG-AFTRA to License Nielsen Streaming Data
NEW YORK SAG-AFTRA has inked a deal with Nielsen to become its third-party provider of streaming content measurement and has announced that it will use the Niel...
02/05/2024
Cineverse Unveils Public Beta of AI-Powered cineSearch
LOS ANGELES Cineverse has debuted cineSearch, its previously announced new content search and discovery service in public Beta....
02/05/2024
Can AI find a way to reduce the broadcast industry's energy consumption?
OpenDrives Trevor Morgan asks if AI has the answer to making data centres for the media and entertainment industry more sustainable By Contributor Published:...
02/05/2024
Bill Baggelaar Asks the Questions: An Unfiltered Look at Media Supply Chain Transformation
Bill Baggelaar Asks the Questions: An Unfiltered Look at Media Supply Chain Tran...
02/05/2024
Two Boston Conservatory at Berklee Alums Nominated for Tony Awards
Two Boston Conservatory at Berklee Alums Nominated for Tony Awards An additional eight alums and two current students performed in nominated productions. By...
02/05/2024
Viewers Call Finding New TV Content Frustrating' in Comcast Advertising Report
A majority of viewers 51% said the difficulty in finding new content on TV c...
02/05/2024
Programming Legend Art Moore Retiring After 53 Years With ABC Stations
Art Moore, who headed production of long-running syndicated series, including Live, said he plans to retire in September as VP of programming for WABC New York....
02/05/2024
Nexstar Will Move The CW Affiliation to WGN Chicago
Nexstar Media Group, which owns The CW, said the network's affiliation will be moving to Nexstar-owned WGN Chicago....
02/05/2024
Future Today Puts First Original Shows on Fawesome Channel (NewFronts)
Future Today said that it plans to launch the first original shows on its Fawesome streaming channel....
02/05/2024
Behind the Music' Returns on Paramount Plus
Behind the Music is back on Paramount Plus with new episodes May 1. Those profiled in the season two episodes are Bell Biv DeVoe, Trace Adkins and Wolfgang Van ...
02/05/2024
All American: Homecoming' Returns on The CW July 8
All American: Homecoming starts season three on The CW Monday, July 8, while season two of 61st Street kicks off Monday, July 22....
02/05/2024
Jerry Seinfeld's Pop-Tart Movie Starts on Netflix May 3
Unfrosted, a movie about the race to create a game-changing breakfast pastry, such as, say, the Pop-Tart, debuts on Netflix May 3. Jerry Seinfeld directs, his f...
02/05/2024
Former BT Sport COO Jamie Hindhaugh joins EMG / Gravity Media
Charlie Cubbon has also been appointed chief operating officer By Matthew Corrigan Published: May 2, 2024 Charlie Cubbon has also been appointed chief ope...
02/05/2024
Durable Goods Signs Lionel Coleman
Durable Goods Signs Lionel Coleman Brie Clayton May 2, 2024 0 Comments Durable Goods has signed multi-hyphenate director Lionel Coleman for commercial...
02/05/2024
Hitsujibungaku's Music Video GO!!! Shot by Kyotaro Hayashi with Blackmagic Cinema Camera 6K
Hitsujibungaku's Music Video GO!!! Shot by Kyotaro Hayashi with Blackmagic C...
02/05/2024
Diamond Sports RSNs Go Dark On Comcast Systems
Bally Sports Regional Networks were taken off Comcast's systems on April 30 when their existing distribution agreement expired and Diamond Sports Group was ...
02/05/2024
Diamond Sports Group, DirecTV Renew Distribution Deal
SOUTHPORT, Conn. and EL SEGUNDO, Calif. Diamond Sports Group ( Diamond or the Company ) and DirecTV have announced that they have reached a multi-year renewal...
02/05/2024
Three Nexstar Stations to Become CW Affiliates
IRVING, Texas Nexstar Media Group has announced that its owned and operated television stations in Chicago, Illinois (DMA #3), Norfolk, Virginia (DMA #43), and ...
02/05/2024
FCC, FTC Ink Agreement to Cooperate on Net Neutrality Enforcement
WASHINGTON, D.C. The Federal Communications Commission and Federal Trade Commission have signed a Memorandum of Understanding to coordinate consumer protection ...
02/05/2024
Haivision Celebrates 20th Anniversary
MONTREAL Haivision Systems Inc. is marking its 20th anniversary by detailing some of the accomplishments and developments that have helped the company become a ...
02/05/2024
Agora Introduces Adaptive Video Optimization Technology
SANTA CLARA, Calif. Agora today unveiled its Adaptive Video Optimization (AVO) technology that uses machine learning to adjust parameters dynamically at every s...
02/05/2024
Study: Streaming Market Is Saturated But Subscriptions Continue to Grow
NEW YORK Kantar has released a new study showing the U.S. streaming market has hit a saturation point, with the household penetration rate stagnating and at nea...
02/05/2024
Samba TV To Spotlight New Capabilities For Generative AI Ad Solution
NEW YORK Samba TV is debuting new capabilities for Samba AI, the company's suite of generative AI technologies, at the 2024 IAB (Interactive Advertising Bur...
02/05/2024
GSTV Pumps Up Research, Programming at NewFront
GSTV, the network that programs screens at gas stations, will be talking about new research and new programming at its NewFront presentation Wednesday....
02/05/2024
EMG / Gravity Media Taps Jamie Hindhaugh To Head Up UK, US, Australia, and Middle East; Names Charlie Cubbon as COO
EMG / Gravity Media appoints Charlie Cubbon COO and Jamie Hindhaugh regional CEO...
02/05/2024
Watch SVG NEXT Conversations, Ep. 2: How XR and Other Emerging Technologies Are Transforming the Landscape of M&E'
Watch SVG NEXT Conversations, Ep. 2: How XR and Other Emerging Technologies Are...
02/05/2024
SVG Sit-Down: Program Productions' Bob Carzoli, Integrum's Kathy Reiland on the Strategy Behind the New Alliance
SVG Sit-Down: Program Productions' Bob Carzoli, Integrum's Kathy Reiland...
02/05/2024
YES Network App Logs Record Usership With New Expanded Pick-N-Play Live Interactivity, YES Rewards
YES Network App Logs Record Usership With New Expanded Pick-N-Play Live Interact...
02/05/2024
Rohde & Schwarz presents its test solutions at CCW 2024 that enable a successful migration to mission-critical broadband
Rohde & Schwarz presents its test solutions at CCW 2024 that enable a successful...
02/05/2024
Baselight training. Paris. Les Lapins Bleus. 27-31 May 2024
Baselight accredited training partner, Les Lapins Bleus, is conducting a five day Baselight training course in Paris in May. Location: Paris Dates: 27-31 May ...
02/05/2024
Skeem Saam: Wednesday's episode, 1 May 2024 [video]
Skeem Saam: Wednesday's episode, 1 May 2024 [video]Missed an episode of Skeem Saam? No problem! Watch the latest episode of your favourite South African soa...
02/05/2024
Prison Journalism: It's alright not to have
Prison Journalism: It's alright not to haveWesley Leong was incarcerated at the age of 15 in 1996 at Pollsmoor Prison. He is currently part of Restore's...
02/05/2024
Tonight on Smoke and Mirrors: Thandiswa's quest to reclaim Caesar's house intensifies
Tonight on Smoke and Mirrors: Lulu navigates the complexities of her relationshi...
02/05/2024
GeForce NOW Delivers 24 A-May-zing Games This Month
GeForce NOW brings 24 new games for members this month. Ninja Theory's highly anticipated Senua's Saga: Hellblade II will be coming to the cloud soon -...
02/05/2024
NVIDIA AI Microservices for Drug Discovery, Digital Health Now Integrated With AWS
Harnessing optimized AI models for healthcare is easier than ever as NVIDIA NIM,...
02/05/2024
ARRI announces the ALEXA 35 Live - Multicam System
ARRI announces the ALEXA 35 Live - Multicam System posted: 02/05/2024 Arri Alexa 35 Live - Multicam System ARRI announces the ALEXA 35 Live - Multicam Sy...
02/05/2024
The Women': Author shines light on forgotten women in war
The Women': Author shines light on forgotten women in warThe bestselling author of The Nightingale', Kristin Hannah, has outdone herself with her new h...