v3 discovery json document does not contain rootURL.
See original GitHub issueEnvironment details
- Python version:
Python 3.7.3
- pip version:
pip 18.1
google-api-python-client
version:1.12.3
Steps to reproduce
- Attempt to build for analytics v3
build("analytics", "v3", ...)
- Receive key error in below stack trace where service does not contain rootURL.
a. traced code back to REST call to: “https://www.googleapis.com/discovery/v1/apis/analytics/v3/rest” b. return from GET to that endpoint does not contain a rootURL entry. c. cooreponding google bugtracker ticket @ https://issuetracker.google.com/u/1/issues/170661562 opened by another person.
Code example
build("analytics", "v3", credentials = get_ga_creds(creds), cache_discovery = False)
Stack trace
~/cddl/sources/google_analytics/extract.py in connect_ga_v3(creds)
48
49 def connect_ga_v3(creds):
---> 50 return build("analytics", "v3", credentials = get_ga_creds(creds), cache_discovery = False)
51
52
/usr/local/lib/python3.7/dist-packages/googleapiclient/_helpers.py in positional_wrapper(*args, **kwargs)
132 elif positional_parameters_enforcement == POSITIONAL_WARNING:
133 logger.warning(message)
--> 134 return wrapped(*args, **kwargs)
135
136 return positional_wrapper
/usr/local/lib/python3.7/dist-packages/googleapiclient/discovery.py in build(serviceName, version, http, discoveryServiceUrl, developerKey, model, requestBuilder, credentials, cache_discovery, cache, client_options, adc_cert_path, adc_key_path, num_retries)
286 client_options=client_options,
287 adc_cert_path=adc_cert_path,
--> 288 adc_key_path=adc_key_path,
289 )
290 break # exit if a service was created
/usr/local/lib/python3.7/dist-packages/googleapiclient/_helpers.py in positional_wrapper(*args, **kwargs)
132 elif positional_parameters_enforcement == POSITIONAL_WARNING:
133 logger.warning(message)
--> 134 return wrapped(*args, **kwargs)
135
136 return positional_wrapper
/usr/local/lib/python3.7/dist-packages/googleapiclient/discovery.py in build_from_document(service, base, future, http, developerKey, model, requestBuilder, credentials, client_options, adc_cert_path, adc_key_path)
492
493 # If an API Endpoint is provided on client options, use that as the base URL
--> 494 base = urljoin(service["rootUrl"], service["servicePath"])
495 if client_options.api_endpoint:
496 base = client_options.api_endpoint
KeyError: 'rootUrl'
Issue Analytics
- State:
- Created 3 years ago
- Reactions:15
- Comments:17 (1 by maintainers)
Top Results From Across the Web
Google API Build Service Object returns KeyError: 'rootUrl'
From a little bit of research here, it seems that the No handlers could be found for logger "oauth2client.util" error can actually be ......
Read more >Using the API | Google API Discovery Service
All calls to the API are unauthenticated, JSON-based, REST requests ... The Discovery document contains a set of API-specific properties:.
Read more >Adding content with the API or tooling - IBM Cloud Docs
If two files have the same name, the original is overwritten when the newer ... JSON and HTML documents are supported by IBM...
Read more >Source Code for Module googleapiclient.discovery
411 412 Args: 413 service: string or object, the JSON discovery ... 417 This parameter is no longer used as rootUrl and servicePath...
Read more >Discovery API - The Ticketmaster Developer Portal
Your API Key should automatically appear in all URLs throughout this portal. Example: https://app.ticketmaster.com/discovery/v2/events.json?apikey={apikey}.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks like it’s fixed now. https://www.googleapis.com/discovery/v1/apis/analytics/v3/rest has ‘rootUrl’ again.
This happened to me also this afternoon, after 5PM EST. It seems the default service discovery document returned by the discovery endpoint of the client library no longer returns the rootUrl property in the document.
I managed to work around it by copying the response of https://www.googleapis.com/discovery/v1/apis/analytics/v3/rest in a JSON file hosted on S3, in that file I added the rootUrl property that the client library expects like this:
"rootUrl" : "https://www.googleapis.com/"
I then overrode the discoveryServiceUrl endpoint on the build method to point to a different service discovery document hosted by me in a custom endpoint:
service = build('analytics', 'v3', http=http, discoveryServiceUrl="https://example.com/service-discovery-v1.json")
Of course, this is a temporary solution for me since I need to keep my software running, but I ideally Google will fix this soon or provide more guidance.
I hope this helps someone.