-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapiCaller.cs
More file actions
37 lines (30 loc) · 1.03 KB
/
apiCaller.cs
File metadata and controls
37 lines (30 loc) · 1.03 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
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Update_Checker
{
internal class apiCaller
{
internal async Task<JSONStruc> mkHttpCall(string url)
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("User-Agent", "ChobbyCodeUpdateChecker");
//Passes the url to the http client and does stuff
using (HttpResponseMessage response = await client.GetAsync(url))
{
using (HttpContent content = response.Content)
{
// Converts json to JSONStruc
string httpResponse = await content.ReadAsStringAsync();
JSONStruc infoHttp = JsonConvert.DeserializeObject<JSONStruc>(httpResponse);
return infoHttp;
}
}
}
}
}
}