-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
34 lines (30 loc) · 1.11 KB
/
Program.cs
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
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace health
{
class Program
{
static async Task Main(string[] args)
{
string baseUrl = "https://api.amerandish.com/v1";
string actionUrl = "/speech/healthcheck";
string authKey = "<YOUR_API_KEY>";
string url = baseUrl+actionUrl;
var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Add("Authorization", string.Format("bearer {0}", authKey));
var client = new HttpClient();
var response = await client.SendAsync(request);
if(response.IsSuccessStatusCode){
// success response
var jsonStr = await response.Content.ReadAsStringAsync();
var model = HealthModel.FromJson(jsonStr);
Console.WriteLine(model);
}else{
// failure response
var jsonStr = await response.Content.ReadAsStringAsync();
Console.WriteLine(jsonStr);
}
}
}
}