# HTTP Error Code: 401 Authorization Required

**URL:** <https://discussions.flightaware.com/t/http-error-code-401-authorization-required/17422>\
**Category:** AeroAPI\
**Created:** [October 9, 2015, 4:17am UTC](https://discussions.flightaware.com/t/http-error-code-401-authorization-required/17422 "2015-10-09T04:17:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dtsinamura](https://sea1.discourse-cdn.com/flex019/user_avatar/discussions.flightaware.com/dtsinamura/32/66578_2.png) [@dtsinamura](https://discussions.flightaware.com/u/dtsinamura)\
**Post date:** [October 9, 2015, 4:17am UTC](https://discussions.flightaware.com/t/http-error-code-401-authorization-required/17422/1 "2015-10-09T04:17:39Z")

</div>

Dear Support,

I am making following query but getting the error Authorization Required.

[name:password@flightxml.flightaw … 1&offset=0](http://name:password@flightxml.flightaware.com/json/FlightXML2/MetarEx?airport=KJFK&startTime=0&howMany=1&offset=0)

Can you guide me for the possible problems?

Please note that I am working on behalf of my client.

Thanks,

---

<div class="post-metadata">

**Author:** ![bovineone](https://sea1.discourse-cdn.com/flex019/user_avatar/discussions.flightaware.com/bovineone/32/117631_2.png) [@bovineone](https://discussions.flightaware.com/u/bovineone)\
**Post date:** [October 9, 2015, 7:02am UTC](https://discussions.flightaware.com/t/http-error-code-401-authorization-required/17422/2 "2015-10-09T07:02:58Z")

</div>

Be sure that you are supplying a FlightXML API key and not your website user password in the request.

---

<div class="post-metadata">

**Author:** ![dtsinamura](https://sea1.discourse-cdn.com/flex019/user_avatar/discussions.flightaware.com/dtsinamura/32/66578_2.png) [@dtsinamura](https://discussions.flightaware.com/u/dtsinamura)\
**Post date:** [October 9, 2015, 9:37am UTC](https://discussions.flightaware.com/t/http-error-code-401-authorization-required/17422/3 "2015-10-09T09:37:46Z")

</div>

Dear Support,

Thanks for your reply. You mean that the user name will be the website user name but the password will not be website password but FlightXML API key.

Am I right?

Thanks,

---

<div class="post-metadata">

**Author:** ![bovineone](https://sea1.discourse-cdn.com/flex019/user_avatar/discussions.flightaware.com/bovineone/32/117631_2.png) [@bovineone](https://discussions.flightaware.com/u/bovineone)\
**Post date:** [October 9, 2015, 9:30pm UTC](https://discussions.flightaware.com/t/http-error-code-401-authorization-required/17422/4 "2015-10-09T21:30:02Z")

</div>

Affirmative. You may request a key from here if you haven’t already: [flightaware.com/commercial/flightxml/key](http://flightaware.com/commercial/flightxml/key)

---

<div class="post-metadata">

**Author:** ![dtsinamura](https://sea1.discourse-cdn.com/flex019/user_avatar/discussions.flightaware.com/dtsinamura/32/66578_2.png) [@dtsinamura](https://discussions.flightaware.com/u/dtsinamura)\
**Post date:** [October 12, 2015, 10:11am UTC](https://discussions.flightaware.com/t/http-error-code-401-authorization-required/17422/5 "2015-10-12T10:11:01Z")

</div>

Dear Support,

I am still getting the ‘Authorization Required’ message. This time I have provided a valid user name and API key in the following form:

[name:API\_KEY@flightxml.flightawa … 1&offset=0](http://name:API_KEY@flightxml.flightaware.com/json/FlightXML2/MetarEx?airport=KJFK&startTime=0&howMany=1&offset=0)

Am I still making some mistake?

Thanks,

---

<div class="post-metadata">

**Author:** ![bovineone](https://sea1.discourse-cdn.com/flex019/user_avatar/discussions.flightaware.com/bovineone/32/117631_2.png) [@bovineone](https://discussions.flightaware.com/u/bovineone)\
**Post date:** [October 12, 2015, 5:30pm UTC](https://discussions.flightaware.com/t/http-error-code-401-authorization-required/17422/6 "2015-10-12T17:30:48Z")

</div>

Your URL does work, so it’s possible you have some slight copy/paste error in the username or API Key. Try starting with one of the example programs provided on the documentation page and modifying just the credentials. Supplying the username and your API Key should be all you need to change.

---

<div class="post-metadata">

**Author:** ![dtsinamura](https://sea1.discourse-cdn.com/flex019/user_avatar/discussions.flightaware.com/dtsinamura/32/66578_2.png) [@dtsinamura](https://discussions.flightaware.com/u/dtsinamura)\
**Post date:** [October 16, 2015, 11:33am UTC](https://discussions.flightaware.com/t/http-error-code-401-authorization-required/17422/7 "2015-10-16T11:33:52Z")

</div>

Dear Support,

I am making a REST based Java program for utilizing the Flight Aware service so I think the following URL will be wrong:

[name:API\_KEY@flightxml.flightawa … 1&offset=0](http://name:API_KEY@flightxml.flightaware.com/json/FlightXML2/MetarEx?airport=KJFK&startTime=0&howMany=1&offset=0)

I will need to do some encoding for name and API key. Am I right?

How can I do this using the JDK only i.e. not using any third party library?

Thanks,

---

<div class="post-metadata">

**Author:** ![bovineone](https://sea1.discourse-cdn.com/flex019/user_avatar/discussions.flightaware.com/bovineone/32/117631_2.png) [@bovineone](https://discussions.flightaware.com/u/bovineone)\
**Post date:** [October 19, 2015, 11:22pm UTC](https://discussions.flightaware.com/t/http-error-code-401-authorization-required/17422/8 "2015-10-19T23:22:02Z")

</div>

We do not provide sample code for accessing our REST/JSON interface from Java, however it is fairly simple to write. You will need to make sure that the requests are being generated in a way that meets our servers’ expectations and that the HTTP authentication is properly formatted.

Alternatively you can use our SOAP/XML interface and use the Apache Axis library sample code that we provide on our documentation website.
