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

googleapiclient.errors.UnknownApiNameOrVersion: name: script version: v1 #194

Open
robguinness opened this issue Mar 4, 2021 · 2 comments

Comments

@robguinness
Copy link

Expected Behavior

The quickstart.py example (https://developers.google.com/apps-script/api/quickstart/python) should run successfully.

Actual Behavior

Exits with the following error:

Traceback (most recent call last):
  File "quickstart.py", line 83, in <module>
    main()
  File "quickstart.py", line 53, in main
    service = build('script', 'v1', credentials=creds)
  File "/home/rob/.venv/lib/python3.8/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/rob/.venv/lib/python3.8/site-packages/googleapiclient/discovery.py", line 273, in build
    content = _retrieve_discovery_doc(
  File "/home/rob/.venv/lib/python3.8/site-packages/googleapiclient/discovery.py", line 387, in _retrieve_discovery_doc
    raise UnknownApiNameOrVersion("name: %s  version: %s" % (serviceName, version))
googleapiclient.errors.UnknownApiNameOrVersion: name: script  version: v1

Steps to Reproduce the Problem

  1. Follow the steps at https://developers.google.com/apps-script/api/quickstart/python

Specifications

  • Python version (python --version): Python 3.8.5
  • OS (Mac/Linux/Windows): Linux
@robguinness
Copy link
Author

I dug a bit deeper, and it seems that static_discovery is not working properly. From the docstring of _retrieve_discovery_doc in googleapiclient/discovery.py:

    static_discovery: Boolean, whether or not to use the static discovery docs
      included in the library.

This path where it is trying to look for the discovery doc does not exist. Is I change the default value of static_discovery to False, then the discovery doc is retrieved from the URL, and everything works fine.

@adrianbn
Copy link

adrianbn commented Mar 6, 2021

This happens with the drive API as well. As @robguinness says, if I pass static_discovery=False to the build call it works fine. Here's the original stack trace:

Traceback (most recent call last):
  File "/Users/adrian/code/erd-watcher/__main__.py", line 109, in <module>
    gdrive_erds(last_check)
  File "/Users/adrian/code/erd-watcher/__main__.py", line 86, in gdrive_erds
    service = build('drive', 'v3', credentials=creds)
  File "/Users/adrian/Library/Caches/pypoetry/virtualenvs/erd-watcher-EyFrJG54-py3.9/lib/python3.9/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Users/adrian/Library/Caches/pypoetry/virtualenvs/erd-watcher-EyFrJG54-py3.9/lib/python3.9/site-packages/googleapiclient/discovery.py", line 272, in build
    content = _retrieve_discovery_doc(
  File "/Users/adrian/Library/Caches/pypoetry/virtualenvs/erd-watcher-EyFrJG54-py3.9/lib/python3.9/site-packages/googleapiclient/discovery.py", line 386, in _retrieve_discovery_doc
    raise UnknownApiNameOrVersion("name: %s  version: %s" % (serviceName, version))

This works:

build('drive', 'v3', credentials=creds, static_discovery=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants