-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
42 lines (38 loc) · 1.3 KB
/
Program.cs
File metadata and controls
42 lines (38 loc) · 1.3 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
using System;
using Com.Lab5e.Span.Api;
using Com.Lab5e.Span.Client;
namespace collections
{
class Program
{
static void Main(string[] args)
{
// Pull the token from the command line. Run with `profile.exe [token]`
// or `dotnet run -- [token]`
if (args.Length < 1)
{
Console.WriteLine("Must specify token on command line");
return;
}
// Set the token in the configuration
var config = new Configuration();
config.ApiKey["X-API-Token"] = args[0];
// Create the API client
var collectionsApi = new CollectionsApi(config);
try
{
// ..and retrieve the profile.
var collectionList = collectionsApi.ListCollections();
foreach (var collection in collectionList.Collections)
{
Console.WriteLine(collection.CollectionId + " " + collection.Tags["name"]);
}
}
catch (ApiException e)
{
// If something fails we'll get an ApiException
Console.WriteLine("Got exception calling API: " + e.Message);
}
}
}
}