-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
33 lines (29 loc) · 1.02 KB
/
Program.cs
File metadata and controls
33 lines (29 loc) · 1.02 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
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
namespace HttpCallExample
{
class Program
{
static async Task Main(string[] args)
{
// Build configuration
var builder = new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
IConfiguration config = builder.Build();
// Get URL from configuration
string url = config["Settings:Url"];
string password = config["Settings:Password"];
string fullUrl = url + password;
// Create an HttpClient instance
using (HttpClient client = new HttpClient())
{
client.Timeout = TimeSpan.FromMinutes(10);
// Make the HTTP GET request
_ = await client.GetAsync(fullUrl);
}
}
}
}