Is there something wrong with my access or the server? I am no longer getting data back. This was working a few days ago, now I test again and it will not return data. Its going straight to the else (Error retrieving data from the server).
Enter flight number:swa 1511
There was an error retrieving the data from the server.
Process finished with exit code 0
import requests
import json
from settings import flight_table
username = “”
apiKey = “”
fxmlUrl = ‘https://flightxml.flightaware.com/json/FlightXML3/’
flight_number = input(‘Enter flight number:’)
payload = {‘ident’: flight_number}
response = requests.get(fxmlUrl + “FlightInfoStatus”, params=payload, auth=(username, apiKey))
if response.status_code == 200:
print(“Aircraft enroute to Need to add this parameter***:”)
decodedResponse = response.json()
print(json.dumps(decodedResponse))
for flight in decodedResponse[‘FlightInfoStatusResult’][‘flights’]:
flight_table.put_item(
Item={
‘fat_flight_id’: flight[‘faFlightID’],
‘airline’: flight[‘airline’],
‘flightnumber’: flight[‘flightnumber’],
‘tailnumber’: flight[‘tailnumber’],
‘type’: flight[‘type’],
‘blocked’: 1 if flight[‘blocked’] else 0,
‘diverted’: 1 if flight[‘diverted’] else 0,
‘cancelled’: 1 if flight[‘cancelled’] else 0,
}
)
else:
print (“There was an error retrieving the data from the server.”)