using System; using System.Text; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; using Newtonsoft.Json; namespace ConsoleApp1 { /*public class OrdinaryUrl { public string? type { get; set; } public string? url { get; set; } public string? suggested_link_text { get; set; } public OrdinaryUrl(string? type, string? url, string? suggested_link_text) { this.type = type; this.url = url; this.suggested_link_text = suggested_link_text; } }*/ /* public class InformationCriminals { [JsonProperty("@id")] public string? Newid { get; set; } [JsonProperty("title")] public string? Title { get; set; } [JsonProperty("field_offices")] public string? Office { get; set; } [JsonProperty("details")] public string? Detail { get; set; } [JsonProperty("sex")] public string? Pol { get; set; } [JsonProperty("nationality")] public string? National { get; set; } [JsonProperty("age_max")] public int? Age { get; set; } [JsonProperty("height_max")] public int? Height { get; set; } [JsonProperty("race_raw")] public string? Race { get; set; } [JsonProperty("hair_raw")] public string? Hair { get; set; } [JsonProperty("languages")] public string? Language { get; set; } [JsonProperty("files")] public string? Urlpdf { get; set; } public InformationCriminals(string? underNewid, string? underTitle, string? underOffice, string? underDetails, string? underPol, string? underNational, int? underAge, int? underHeight, string? underRace, string? underHair, string? underLanguage, string? underPdf) { this.Newid = underNewid; this.Title = underTitle; this.Office = underOffice; this.Detail = underDetails; this.Pol = underPol; this.National = underNational; this.Age = underAge; this.Height = underHeight; this.Race = underRace; this.Hair = underHair; this.Language = underLanguage; this.Urlpdf = underPdf; } }*/ class Contributor { public string items { get; set; } public override string ToString() { return $"{items} "; } } class Program { private static async Task Main() { using var client = new HttpClient(); client.BaseAddress = new Uri("https://api.fbi.gov/wanted/v1/list"); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); var url = "https://api.fbi.gov/wanted/v1/list"; HttpResponseMessage response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); var resp = await response.Content.ReadAsStringAsync(); List contributors = JsonConvert.DeserializeObject>(resp); contributors.ForEach(Console.WriteLine); } } } /*class WantedPersons { public string title { get; set; } public char dates_of_birth_used { get; set; } public string nationality { get; set; } public string race_raw { get; set; } public string race { get; set; } public string hair_raw { get; set; } public string place_of_birth { get; set; } public string person_classification { get; set; } public string description { get; set; } public int height_max { get; set; } public int height_min { get; set; } public override string ToString() { return $"{title}: {dates_of_birth_used}: {nationality} nationality: {race_raw}:" + $" {race}: {hair_raw}: {place_of_birth}: {person_classification}: {description}:" + $"{height_max}: {height_min}"; } } class Program { static async Task Main(string[] args) { using var client = new HttpClient(); client.BaseAddress = new Uri("https://www.fbi.gov/wanted"); client.DefaultRequestHeaders.Add("MostWanted Persons", ""); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); var url = "repos/symfony/symfony/persons"; HttpResponseMessage response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); var resp = await response.Content.ReadAsStringAsync(); List persons = JsonConvert.DeserializeObject>(resp); persons.ForEach(Console.WriteLine); }*/