const string username = "em...@gmail.com";
const string password = "MyPassword";
var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpContent content = new StringContent($"username={username}&password={password}", Encoding.UTF8, "application/x-www-form-urlencoded");
var uri = new Uri("https://datafeeds.nationalrail.co.uk/authenticate");
var response = client.PostAsync(uri, content).Result;
if (!response.IsSuccessStatusCode)
{
throw new AggregateException($"{response.StatusCode} ({response.ReasonPhrase})");
}
return response.Content.ReadAsStringAsync().Result;