首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >调用amadeus航班提供api时出现错误

调用amadeus航班提供api时出现错误
EN

Stack Overflow用户
提问于 2022-07-24 14:53:47
回答 1查看 83关注 0票数 0

嗨,我正在尝试amadeus飞行提供搜索api,但得到400错误,交叉检查我的客户端和秘密ID,它的正确不确定是否有任何问题的api或什么。

代码:

代码语言:javascript
复制
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)

异常:

代码语言:javascript
复制
 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]
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-26 09:47:08

在API调用中,缺少强制参数adults。有关更多细节,请查看API参考

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73099459

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档