diff --git a/describe.py b/describe.py index 2537e7c06e..c1bcd69215 100755 --- a/describe.py +++ b/describe.py @@ -389,6 +389,16 @@ def document_api(name, version, uri): """ try: service = build(name, version) + + http = build_http() + response, content = http.request( + uri or uritemplate.expand( + FLAGS.discovery_uri_template, {"api": name, "apiVersion": version} + ) + ) + if 'status' in response: + if response['status'] == '404': + raise UnknownApiNameOrVersion except UnknownApiNameOrVersion as e: print("Warning: {} {} found but could not be built.".format(name, version)) return @@ -396,12 +406,6 @@ def document_api(name, version, uri): print("Warning: {} {} returned {}.".format(name, version, e)) return - http = build_http() - response, content = http.request( - uri or uritemplate.expand( - FLAGS.discovery_uri_template, {"api": name, "apiVersion": version} - ) - ) discovery = json.loads(content) version = safe_version(version)