Quote:
I don't know what is the class I should use to get the data
Assuming you're on a recent version of .NET, try the
HttpClient Class[
^].
string TargetUrl = "...";
string Username = "...";
string Password = "...";
var client = new HttpClient();
var byteArray = Encoding.ASCII.GetBytes(Username + ":" + Password);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
using (var response = await client.GetAsync(TargetUrl))
{
response.EnsureSuccessStatusCode();
string json = await response.Content.ReadAsStringAsync();
... DO SOMETHING WITH THE JSON HERE ...
}
If you're using .NET Framework 4.5 or 4.6, you'll need to add a reference to the NuGet package:
NuGet Gallery | System.Net.Http 4.3.4[
^]