FlightXML2 not working for me


#1

Hello, I hope someone can help me. I have been using a script in Google Script to fetch information in FlightXML2 but it stopped working recently, with the error “Exception: Bad request: http://flightxml.flightaware.com/json/FlightXML2/FlightInfoEx” I can’t seem to get any more information from the request than that. Does someone have a good way to troubleshoot why it suddenly stopped working? Code below, API obviously changed.

    function makeRequest(method, url, payload) {
//payload = { "ident": id, "howMany": "4" }
//url = "FlightInfoEx"
//method = "GET"
      var BASE_URL = "flightxml.flightaware.com/json/FlightXML2/"
      var USER = "joblio";
      var API_KEY = "b______________________________3";
      var options = {
        method: method,
        headers: {
          "Authorization" : "Basic " + Utilities.base64Encode(USER + ':' + API_KEY)
        },
        payload: payload
      };
        
      var response = UrlFetchApp.fetch(BASE_URL + url, options);
      var json = response.getContentText();
      var data = JSON.parse(json);
      
      return data;
    }

Header information (partially blocked):
{headers={Authorization=Basic am9ibGlvOmI5MTY5YzI1ZDMwMDU_____________WVjZGZlNzdjOWUxYjdmYjM=}, method=GET, payload={ident=N12345, howMany=4}}

Response:
Exception: Bad request: http://flightxml.flightaware.com/json/FlightXML2/FlightInfoEx

Thanks for any help.


#2

After further testing, it seems perhaps that flightxml.flightaware.com/json/FlightXML2 is not working for many uses. AirlineInfo with AirlineCode UAL shows unknown airline INVALID. Metar for KLAX shows invalid code.


#3

Are you still experiencing these issues? I just attempted the methods you mention and it appears that all of them are currently working. Can you confirm that?


#4

Hi cbw, thanks for your response.

I am still getting invalid data / no data available / unknown airline INVALID for the test I am doing.

I AM able make it work and get data if I pass the query in the URL query string, but not if I put the parameters in the header. I can put my username and api (encoded in base64) in the header, but nothing else it seems.

Yes, I can make my project work with the URL query string method, now that I have figured out that it works that way. But I haven’t been successful in making it work in the way it was previously working.

Again, thank you for your response, cbw. It made me look further into the problem and find a way that works.


#5

Checking in the logs on what you are querying, we are seeing some requests that are missing some or all of the needed parameters. Please verify the requests are being formed properly before being sent.


#6

Yes, in the FlightInfoEx request, I was missing the “offset” parameter, but it didn’t seem to be needed previously (>3 weeks ago), perhaps defaulting to zero if not defined. If the malformed part of my header includes the authorization, I’m afraid I’m not advanced enough to diagnose problems with it. In any case, I got it working with the parameters in the URL string.

Thanks again.