forked from rosette-api/csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo.cs
More file actions
47 lines (45 loc) · 1.53 KB
/
info.cs
File metadata and controls
47 lines (45 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using rosette_api;
namespace rosette_apiExamples
{
class info
{
/// <summary>
/// Example code to call Rosette API to get information such as version and build.
/// Requires Nuget Package:
/// rosette_api
/// </summary>
static void Main(string[] args)
{
//To use the C# API, you must provide an API key
string apikey = "Your API key";
string alturl = string.Empty;
//You may set the API key via command line argument:
//info yourapikeyhere
if (args.Length != 0)
{
apikey = args[0];
alturl = args.Length > 1 ? args[1] : string.Empty;
}
try
{
CAPI InfoCAPI = string.IsNullOrEmpty(alturl) ? new CAPI(apikey) : new CAPI(apikey, alturl);
//The results of the API call will come back in the form of a Dictionary
RosetteResponse response = InfoCAPI.Info();
foreach (KeyValuePair<string, string> h in response.Headers) {
Console.WriteLine(string.Format("{0}:{1}", h.Key, h.Value));
}
Console.WriteLine(response.ContentAsJson);
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
}
}
}