更新时间:2021-07-29 06:12:07
有三件事造成了503错误.
There were three things that were creating the 503 error.
Firstly, I needed to make the method or entire Api require an Api Key. In this case I just applied it to the entire Api:
@endpoints.api(name='practice', version='v1', api_key_required=True)
class PracticeApi(remote.Service):
第二,在云控制台中生成Api密钥后,我需要在部署密钥之前,将密钥放入openapi.json文件.
Secondly, after I generated the Api Key in the cloud console I needed to put the Key into the openapi.json file before deploying it.
最后,我仍然收到验证错误:
Lastly, I was still getting a validation error:
ValidationError: Expected type <type 'unicode'> for field content, found (u'My Api Key', Variant(STRING, 9)) (type <type 'tuple'>)
get_unrecocoizedized_field_info()函数返回(值的元组,变体).响应未预期有元组,因此我将方法更新为仅显示值:
The get_unrecognized_field_info() function returns a tuple of (value, variant). A tuple was not expected by the response so I updated the method to only show value:
def test_api_key(self, request):
return TestResponse(content=request.get_unrecognized_field_info('key')[0])