I keep getting “{“The data contract type ‘FlightawareServiceReference.ArrayOfFlightInfoStatusStruct’ cannot be deserialized because the required data members ‘PropertyChanged, flightsField, next_offsetField’ were not found.”}”
when trying to deserialize the result.
have any idea why and what to do?
Here is the code -
private const string fxmlUrl = “http://flightxml.flightaware.com/json/FlightXML3”;
private const string username = “MYUSERNAME”;
private const string apiKey = “MYAPIKEY”;
private static UriBuilder uriBuilder = new UriBuilder(fxmlUrl);
public static void GetFlightData(string flightName)
{
var requestUrl = fxmlUrl.AppendPathSegment("FlightInfoStatus")
.SetQueryParams(new { ident = "CAP85" });
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);
try
{
var arrayOfFlightInfoStatusStruct = serializer.ReadObject(await streamTask);// as ArrayOfFlightInfoStatusStruct;
}catch(Exception e)
Thanks