Lionel is a C#/XAML developer based in Switzerland. He enjoys developing for Microsoft platforms (mobile, tablets, desktop). He loved to code because “it is the most creative tool that has been given to me – you think, create, and make everyday a better day!”
We’ve asked him to write the post below. Enjoy!
The Unirest HTTP request library was ported sometime back for the classic .NET platform and WinRT. They were packaged in 2 different libraries targeting their respective platforms.
The good news is that the library has now been unified into a single Portable Class Library (PCL) which makes Unirest available for all classic .NET 4, Windows Phone 8, Windows 8, and Silverlight 5 applications. A Nuget package will be published in the coming weeks.
To illustrate and demonstrate the unification of Unirest within the .NET environment, I developed the ApiWorld app collection which consist of 3 quick and simple apps running on Windows 8, Windows Phone 8 and WPF, all using the new library.
ApiWorld is a simple app that allows you to browse through APIs publicly available in Mashape. (As these apps are only an illustration of Unirest on .NET platforms, their functionality is solely limited to loading basic Mashape APIs information).
Now let’s dive a little bit into the specific implementation that shows how easy it is to use Unirest.
var result = await Unirest.get("https://mashape.p.mashape.com/apis") .header("X-Mashape-Authorization", "MyApiKey") .asJsonAsync<ApisResult>();
Then just nicely wrap this code into a service class that you can share between all your .NET apps and you’re done! If you want to see a little more you can get the full source code of the app collection from the ApiWorld demo Github page. (Click here to check out the service class where Unirest was used).