Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.0.2 causes UnknownApiNameOrVersion for trends v1beta when attempting service build #1263

Closed
reytchison opened this issue Mar 19, 2021 · 2 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@reytchison
Copy link

reytchison commented Mar 19, 2021

Environment details

  • OS type and version: Windows 10
  • Python version: 3.8.5
  • pip version: 21.0.1
  • anaconda version: conda 4.9.2
  • google-api-python-client version: 2.0.2

Steps to reproduce

  • NOTE: Code works with 1.12.8 of google-api-python-client. The error occurs with version 2.0.2.
    1. Create discovery URL for version 'v1beta' of api 'trends' .
    2. Attempt to build a service for that URL

Code example

    discovery_url = 'https://trends.googleapis.com/$discovery/rest?version=v1beta'
    service = build('trends', 'v1beta', developerKey=api_key,
                    discoveryServiceUrl=discovery_url)

Stack trace

Traceback (most recent call last):
  File "trends.py", line 192, in <module>
    t = Trends()
  File "trends.py", line 23, in __init__
    self.service = build('trends', self.api_version, developerKey=self.key,
  File "C:\ProgramData\Anaconda3\envs\trends-code\lib\site-packages\googleapiclient\_helpers.py", line 134, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\ProgramData\Anaconda3\envs\trends-code\lib\site-packages\googleapiclient\discovery.py", line 273, in build
    content = _retrieve_discovery_doc(
  File "C:\ProgramData\Anaconda3\envs\trends-code\lib\site-packages\googleapiclient\discovery.py", line 387, in _retrieve_discovery_doc
    raise UnknownApiNameOrVersion("name: %s  version: %s" % (serviceName, version))
googleapiclient.errors.UnknownApiNameOrVersion: name: trends  version: v1beta

Notes

  • I notice that trends with version 'v1beta' is not listed on the supported APIs here However, it still works with the older version of the package (1.12.8) and 'v1beta' was the version initially recommended to me by a Google employee.
@busunkim96
Copy link
Contributor

Hi @reytchison,

I think you're running into #1225. That has been resolved in #1261 , so the code you have now will work with the next release of this library.

For now, just add static_discovery=False to the build call.

    discovery_url = 'https://trends.googleapis.com/$discovery/rest?version=v1beta'
    service = build('trends', 'v1beta', developerKey=api_key,
                    discoveryServiceUrl=discovery_url, static_discovery=False)

@busunkim96 busunkim96 added the type: question Request for information or clarification. Not an issue. label Mar 19, 2021
@busunkim96 busunkim96 self-assigned this Mar 19, 2021
@reytchison
Copy link
Author

Thanks!

rmistry added a commit to rmistry/clusterfuzz that referenced this issue Feb 13, 2024
jonathanmetzman pushed a commit to google/clusterfuzz that referenced this issue Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants