python-3.xamadeus

error in response while calling amadeus flight offer api


Hi I'm trying amadeus api flight offer search api but getting 400 error, cross checked my client and secret ID and its correct not sure is there any issue with api or what.

code:

from amadeus import Client, ResponseError, Location
import json

AMADEUS = Client(
    client_id='my client id',
    client_secret='my secret'
)
try:
    response = AMADEUS.shopping.flight_offers_search.get(
        originLocationCode='MAD',
        destinationLocationCode='ATH',
        departureDate='2022-07-26')
    resp = json.dumps(response.data, indent=4)
    resp = json.loads(resp)
    # print(resp)
    print(resp)
except ResponseError as error:
    print(error)

Exception:

 File "C:\Users\ASUS\python_workspace\python_practiceCode\test_file.py", line 261, in <module>
    response = AMADEUS.shopping.flight_offers_search.get(
  File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\amadeus\shopping\_flight_offers_search.py", line 32, in get
    return self.client.get('/v2/shopping/flight-offers', **params)
  File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\amadeus\mixins\http.py", line 40, in get
    return self.request('GET', path, params)
  File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\amadeus\mixins\http.py", line 110, in request
    return self._unauthenticated_request(
  File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\amadeus\mixins\http.py", line 126, in _unauthenticated_request
    return self.__execute(request)
  File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\amadeus\mixins\http.py", line 152, in __execute
    response._detect_error(self)
  File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\amadeus\mixins\parser.py", line 16, in _detect_error
    self.__raise_error(error, client)
  File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\amadeus\mixins\parser.py", line 67, in __raise_error
    raise error
amadeus.client.errors.ClientError: [400]

Solution

  • In your API call, you are missing the mandatory parameter adults. Please check out the API reference for more details.