【问题标题】:Getting 503: 'Service Unavailable' when using Amadeus Airport Search autocomplete API使用 Amadeus Airport Search 自动完成 API 时出现 503:“服务不可用”
【发布时间】:2021-05-29 08:48:42
【问题描述】:

为什么我会收到 503 服务不可用?

我正在列出通过 python 发出的请求响应并启用日志

def origin_airport_search(request):    
    try:
        data = []
        data = amadeus.reference_data.locations.get(keyword=request.GET.get('term', None), subType=Location.ANY).data
    except ResponseError as error:
        messages.add_message(request, messages.ERROR, error)
    response = HttpResponse(get_city_airport_list(data), 'application/json')
    response['Access-Control-Allow-Origin'] = '*'
    return response

def get_city_airport_list(data):
    result = []
    for i, val in enumerate(data):
        result.append(data[i]['iataCode']+', '+data[i]['name'])
    result = list(dict.fromkeys(result))
    return json.dumps(result)
Request
{'app_id': None,
 'app_version': None,
 'bearer_token': 'Bearer j3LmvpBQAKf4ANo16LZlDA6H0IDd',
 'client_version': '5.0.0',
 'headers': {'Accept': 'application/json, application/vnd.amadeus+json',
             'Authorization': 'Bearer j3LmvpBQAKf4ANo16LZlDA6H0IDd',
             'Content-Type': 'application/vnd.amadeus+json',
             'User-Agent': 'amadeus-python/5.0.0 python/3.7.9'},
 'host': 'test.api.amadeus.com',
 'http_request': <urllib.request.Request object at 0x000001CBDDC54488>,
 'language_version': '3.7.9',
 'params': {'keyword': 'kol', 'subType': 'AIRPORT,CITY'},
 'path': '/v1/reference-data/locations',
 'port': 443,
 'scheme': 'https',
 'ssl': True,
 'url': 'https://test.api.amadeus.com/v1/reference-data/locations?keyword=kol&subType=AIRPORT%2CCITY',
 'verb': 'GET'}
Response
{'body': '{"errors":[{"status":503,"code":19,"title":"No available service for '
         'processing the request.","source":{"pointer":"uri"}}]}',
 'data': None,
 'headers': <http.client.HTTPMessage object at 0x000001CBDDD35C88>,
 'http_response': <HTTPError 503: 'Service Unavailable'>,
 'parsed': True,
 'request': <amadeus.client.request.Request object at 0x000001CBDD8BD988>,
 'result': {'errors': [{'code': 19,
                        'source': {'pointer': 'uri'},
                        'status': 503,
                        'title': 'No available service for processing the '
                                 'request.'}]},
 'status_code': 503}

编辑:它现在在 Windows 上运行可能是 amadeus 在测试环境中出现了一些服务器错误。感谢 Anthony 提到这一点。

我需要另一个帮助 - 当我在 MAC 中运行相同的代码时,它会给我这个 ssl 错误响应。

Request
{'app_id': None,
 'app_version': None,
 'bearer_token': None,
 'client_version': '5.0.0',
 'headers': {'Accept': 'application/json, application/vnd.amadeus+json',
             'Content-Type': 'application/x-www-form-urlencoded',
             'User-Agent': 'amadeus-python/5.0.0 python/3.9.2'},
 'host': 'test.api.amadeus.com',
 'http_request': <urllib.request.Request object at 0x109523fd0>,
 'language_version': '3.9.2',
 'params': {'client_id': 'client-key',
            'client_secret': 'client-secret',
            'grant_type': 'client_credentials'},
 'path': '/v1/security/oauth2/token',
 'port': 443,
 'scheme': 'https',
 'ssl': True,
 'url': 'https://test.api.amadeus.com/v1/security/oauth2/token',
 'verb': 'POST'}
Response
{'body': None,
 'data': None,
 'headers': {},
 'http_response': URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)')),
 'parsed': False,
 'request': <amadeus.client.request.Request object at 0x109523e50>,
 'result': None,
 'status_code': None}

【问题讨论】:

  • 可能是他们的服务器宕机了?通过 Amadeus 支持检查 API 状态。
  • 很抱歉给您带来不便,机场和城市搜索 API 在测试环境中出现问题。现在一切都应该修复了,你能不能再试试你的代码,让我们知道它是否适合你。

标签: python amadeus


【解决方案1】:

我从 JS 尝试过,我也得到 503 错误。我在 2021 年 3 月 3 日尝试过。似乎测试环境 API 仍然损坏。

GET https://safer-trip.herokuapp.com/api/users/citySafetyScore/?city=BANGALORE 503 (Service Unavailable)
(anonymous) @ xhr.js:184
e.exports @ xhr.js:13
e.exports @ dispatchRequest.js:50
Promise.then (async)
u.request @ Axios.js:61
r.forEach.u.<computed> @ Axios.js:76
(anonymous) @ bind.js:9
onClick @ index.js:32
l @ react-dom.production.min.js:14
p @ react-dom.production.min.js:14
(anonymous) @ react-dom.production.min.js:14
y @ react-dom.production.min.js:15
at @ react-dom.production.min.js:52
ot @ react-dom.production.min.js:51
lt @ react-dom.production.min.js:52
pt @ react-dom.production.min.js:56
I @ react-dom.production.min.js:287
$ @ react-dom.production.min.js:19
Jt @ react-dom.production.min.js:70
Gt @ react-dom.production.min.js:69
t.unstable_runWithPriority @ scheduler.production.min.js:19
Vo @ react-dom.production.min.js:122
M @ react-dom.production.min.js:287
Xt @ react-dom.production.min.js:68
index.js:46 Error: Request failed with status code 503
    at e.exports (createError.js:16)
    at e.exports (settle.js:17)
    at XMLHttpRequest.p.onreadystatechange (xhr.js:69)

【讨论】:

  • 机场和城市搜索 API 似乎在测试和生产中都可以使用(刚刚使用 test.api.amadeus.com/v1/reference-data/… 进行了测试)。我尝试了 Python SDK 的 python 示例,似乎对我来说工作正常。能否在 Node SDK (github.com/amadeus4dev/amadeus-node#logging--debugging) 中添加调试日志级别以获取更多信息?
  • 嗨 Anthony,我在 Windows 上再次尝试了这个,它现在可以工作了,我在我的 mac 上尝试了完全相同的代码和相同的请求,我得到了这个响应 'http_response': URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:证书链中的自签名证书 (_ssl.c:1123)')),您能帮我看看哪里出错了吗?
  • 我不是专家,但如果你搜索“Certificate_verify_failed python macos”,你会发现很多帖子。我自己没有尝试过,但我看到了与这篇博文中解释的类似的解决方案:medium.com/@yen.hoang.1904/…
猜你喜欢
  • 2016-09-13
  • 2020-08-23
  • 2016-10-07
  • 1970-01-01
  • 1970-01-01
  • 2011-07-18
  • 2018-11-12
  • 1970-01-01
  • 2021-04-05
相关资源
最近更新 更多