Hi there, I’m trying to use the JSON feature with the flightXML2.0. When I build the URL (below) and request it via a web browser - it works (that is - I get a valid reply with valid data).
Exception in thread “main” java.io.IOException: Server returned HTTP response code: 401 for URL:
http://hexa:MY_KEY@flightxml.flightaware.com/json/FlightXML2/MetarEx?airport=KJFKK&startTime=0&howMany=1&offset=0
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1459)
at com.flightaware1.RunTest1.main(RunTest1.java:23)
Any idea why I can’t get the reply just as if I post it in a web browser? Many thanks!
HTTP 401 means you have not supplied the Authorization header in the request with your API credentials. You must use HTTP Basic Auth with your username and your FlightXML API key as your password.