Hi
I have test the FlightInfoStatus API with few flights like UAL0001//LH1340//UAL1//UA1//DLH1340
for all of them I got no flights so probably I’m doing something wrong.
here is the code
static void Main(string args)
{
string fxmlUrl = “http://flightxml.flightaware.com/json/FlightXML3”;
string username = “myusername”;
string apiKey = “myapiKey”;
var uriBuilder = new UriBuilder(fxmlUrl);
var requestUrl = fxmlUrl
.AppendPathSegment("FlightInfoStatus")
.SetQueryParams(new
{
ident = "UAL0001"//LH1340//UAL1//UA1//DLH1340
});
ProcessRepositories(requestUrl, username, apiKey).Wait();
}
private static async Task ProcessRepositories(string apiUrl, string username, string apiKey)
{
var serializer = new DataContractJsonSerializer(typeof(ArrayOfFlightInfoStatusStruct));
var client = new HttpClient();
var credentials = Encoding.ASCII.GetBytes(username + ":" + apiKey);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(credentials));
var streamTask = client.GetStreamAsync(apiUrl);
//var airportInfo1 = serializer.ReadObject(await streamTask);
var airportInfo = serializer.ReadObject(await streamTask) as ArrayOfFlightInfoStatusStruct;
foreach (FlightInfoStatusStruct item in airportInfo.flights)
{
Console.WriteLine("actual_arrival_time - " + item.actual_arrival_time);
Console.WriteLine("aircrafttype - " +item.aircrafttype);
Console.WriteLine("actual_departure_time - " +item.actual_departure_time);
}
}