Reputation: 27
I've just registered my test app and got Api key and Api secret. I'm trying to send request using Python SDK:
from amadeus import Client, ResponseError
amadeus1 = Client(
client_id='my_API_key_here',
client_secret='my_secret_key_here'
)
response = amadeus1.reference_data.locations.airports.get(longitude=49.000, latitude=2.55)
print(response.data)
I receive Network Error. What am I doing wrong?
Upvotes: 1
Views: 966
Reputation: 81
I had this problem again a few days ago. My problem was sending requests from my local environment. It was trying to validate the SSL and that caused issues.
I solved it by including an 'unverified context' to be used by the urlopen
. This should not be used in a production environment. It works making requests to both Amadeus test and production environments from my local machine.
import ssl
def ssl_disabled_urlopen(endpoint):
context = ssl._create_unverified_context()
return urlopen(endpoint, context=context)
amadeus = Client(
client_id = '<client_id>',
client_secret = '<client_secret>',
http=ssl_disabled_urlopen
)
Upvotes: 1
Reputation: 1481
EDIT:
The problem came from an SSL certificate issue on the dev environment.
I cannot reproduce the problem, the API seems to work. Your example returns an empty array because the data in the test environment are limited. For this API the countries covered are: United States, Spain, United Kingdom, Germany & India.
So if you try with London's geolocation
response = amadeus1.reference_data.locations.airports.get(longitude=0.1278, latitude=51.5074)
As you can see, the response contains data.
But I don't have a Network issue. If you still face the issue please contact our support through our portal, share your username so we can check your API Key and API Secret.
Upvotes: 0