//takes lat and lon from national park DB table public async Task <IActionResult> Trails(string lon, string lat, string name) { using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri("https://www.hikingproject.com"); var response = await client.GetAsync( $"/data/get-trails?lat={lat}&lon={lon}&maxDistance=200&sort=distance&maxResults=100&key=200238177-24a146be40fa02014108db565b54b2ed"); response.EnsureSuccessStatusCode(); var stringresult = await response.Content.ReadAsStringAsync(); JObject result = JObject.Parse(stringresult); //only need if you want to get a subsection of data IList <JToken> rawTrailsList = result["trails"].Children().ToList(); List <Trail> trails = new List <Trail>(); foreach (JToken item in rawTrailsList) { Trail singleTrail = item.ToObject <Trail>(); trails.Add(singleTrail); } //save to in-memory repository _repository.AddTrails(trails); ViewBag.NationalPark = name; return(View(trails)); } }