//finds and populates a summoner object with data from the API. //returns null and prints the exception if something goes wrong. public static async Task <Summoner> FillSummoner(string apiKey, string summonerName, HttpClient client) { //always clear headers first so you can call consecutively.. client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Add("X-Riot-Token", apiKey); try{ var result = await client.GetStreamAsync(baseUrl + "/lol/summoner/v3/summoners/by-name/" + summonerName); var serializer = new DataContractJsonSerializer(typeof(Summoner)); Summoner summoner = serializer.ReadObject(result) as Summoner; Console.WriteLine("Summoner: " + summoner.name + "\n Level: " + summoner.summonerLevel); return(summoner); } catch (Exception e) { Console.WriteLine(e.ToString()); return(null); } }