-
Notifications
You must be signed in to change notification settings - Fork 0
/
helloworld.csx
38 lines (29 loc) · 1005 Bytes
/
helloworld.csx
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
using System.Net.Http;
using System.Collections.Generic;
public partial class CurRates
{
[JsonProperty("base")]
public string Base { get; set; }
[JsonProperty("date")]
public DateTimeOffset Date { get; set; }
[JsonProperty("time_last_updated")]
public long TimeLastUpdated { get; set; }
[JsonProperty("rates")]
public Dictionary<string, double> Rates { get; set; }
}
Console.WriteLine("Hello world!");
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://api.exchangerate-api.com/v4/latest/");
client.DefaultRequestHeaders.Accept.Clear();
//HTTP GET
var responseTask = client.GetAsync("EGP");
responseTask.Wait();
var result = responseTask.Result;
if (result.IsSuccessStatusCode)
{
var readTask = result.Content.ReadAsAsync<CurRates>();
readTask.Wait();
CurRates root = readTask.Result;
}
}