【发布时间】: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 在测试环境中出现问题。现在一切都应该修复了,你能不能再试试你的代码,让我们知道它是否适合你。