How to encode the url to get correct data from Flightxml

I am trying to connect to flightxml using SearchBirdeyeInFlight method. I had to encode the query part of the url using UTF8 encoder but it returns wrong data. The Geoevent server I am using doesn’t recognize { or = so I have to encode it. Unfortunately, the encoded url doesnt return the lat longs within the range. Please help!!

http://flightxml.flightaware.com/json/FlightXML2/SearchBirdseyeInFlight?query={range lat 38.8863 40.897669} {range lon -79.03655 -77.1236 }

encoded url:

https://flightxml.flightaware.com/json/FlightXML2/SearchBirdseyeInFlight?query\x3D\x7B\x72\x61\x6E\x67\x65\x20\x6C\x61\x74\x20\x33\x38\x2E\x38\x38\x36\x33\x20\x34\x30\x2E\x38\x39\x37\x36\x36\x39\x7D\x20\x7B\x72\x61\x6E\x67\x65\x20\x6C\x6F\x6E\x20\x2D\x37\x39\x2E\x30\x33\x36\x35\x35\x20\x2D\x37\x37\x2E\x31\x32\x33\x36\x7D\x26\x6F\x66\x66\x73\x65\x74\x3D\x30\x20\x20

1 Like

You need to use standard percent encoding in URLs. Percent-encoding - Wikipedia

If your environment does not allow you to properly pass the intended arguments on the GET URL, you may alternatively convert it to a POST request and provide the arguments in body. POST (HTTP) - Wikipedia

Thanks for replying!!
but even with percent encoding it doesn’t return the desired latitude and longitudes . Tried the below url in a browser and it returns data but not within the specified range of lat /long

https://flightxml.flightaware.com/json/FlightXML2/SearchBirdseyeInFlight?query%3D{range+lat+38.8863+40.897669}+{range+lon+-79.03655+-77.1236}

I believe the equal sign and ampersand characters cannot be encoded, since that is only done when you want to actually include those literal characters in the name or value.

1 Like

That helped !! I left the ‘=’ and encoded the rest of the url. Thanks so much!!

1 Like