FlightAware API through Matlab


#1

I am trying to use FlightAware API through Matlab but I am getting an error.

The code I am using is

webpage='http://brunoacs:MY_API_CODE@flightxml.flightaware.com/json/FlightXML2/Departed?airport=SBBR&howMany=15&filter=airline&offset=0
json_data=urlread(webpage)

the error message is:

urlread at 111 Error downloading URL. Your network connection may be down or your proxy settings improperly configured.

The URL works fine in Chrome.

Matlab seems to use the following protocol,

urlConnection=sun.net.www.protocol.http.HttpURLConnection:http://brunoacs:MY_API_code@flightxml.flightaware.com/json/FlightXML2/Departed?airport=SBBR&howMany=15&filter=airline&offset=0

the error is being raised by the urlConnection.getInputStream method.

Any help is appreciated.

Regards,

Bruno Silva


#2

Have you tried specifying the username and API key to the urlread function by using the named “Username” and “Password” arguments, rather than encoding them in the URL?
mathworks.com/help/matlab/ref/urlread.html

Does your network require a proxy server?


#3

yes I tried that, actually with this solution the function just encodes the username and password in the end of the URL , like flightxml.flightaware.com/json/F … MY_API_KEY). This URL did not work in Chrome (it prompted me for username and password, after passing them I managed to get the data

I am not using a proxy server as well.

Any other ideas? Thanks for the support.


#4

The documentation for urlread() implies you can specify username/password arguments to it, not append them into the URL.



webpage='http://flightxml.flightaware.com/json/FlightXML2/Departed?airport=SBBR&howMany=15&filter=airline&offset=0';
json_data = urlread(webpage, 'Username', 'brunoacs', 'Password', MY_API_CODE, 'Timeout',30);



#5

oh, I think I didn`t get my meaning across… I meant that the urlread function , internally, appends username and password information on the url.

I made some more research and found other people with similar issues, tried everything but no luck so far…

mathworks.com/matlabcentral … of-records
mathworks.com/matlabcentral … ab-7-0-r14

well I think I will try to do it in Java. I will probably need to learn a little bit, but it might be worth it!

Thanks anyway,

Bruno


#6

I would be very surprised if they are internally appending the username/password to the end of the URL. Were you able to try my sample code from my prior post?

Writing it directly in Java would ultimately give you the most control, but may involve more complexity beyond just learning Java since you will also have to pass data between the Matlab APIs.