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

pollen API not available #2415

Closed
MicZet opened this issue Jun 12, 2024 · 2 comments
Closed

pollen API not available #2415

MicZet opened this issue Jun 12, 2024 · 2 comments
Assignees

Comments

@MicZet
Copy link

MicZet commented Jun 12, 2024

Thanks for stopping by to let us know something could be better!

Environment details

  • OS type and version: Ubuntu 22 (but any in fact)
  • Python version: python --version 3.11.2
  • pip version: pip --version pip 23.0.1
  • google-api-python-client version: pip show google-api-python-client 2.133.0

Steps to reproduce

  1. execute example script (pasted below)

Code example

from googleapiclient.discovery import build

api_service_name = "pollen"
api_version = "v1"
endpoint = build(api_service_name, api_version, developerKey=api_key)
print(endpoint) # here already error, rest not even executed


lat = {
    "latitude": 11.7898095,
    "longitude": 13.0238652,
}
metadata = {
    "location": lat,
    "days": 5,
}
request = endpoint.forecast().lookup(
    body=metadata
)

response = request.execute()

Stack trace

    endpoint = build(api_service_name, api_version, developerKey=api_key)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/m/.venvs/pythonenv/lib/python3.11/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/m/.venvs/pythonenv/lib/python3.11/site-packages/googleapiclient/discovery.py", line 304, in build
    content = _retrieve_discovery_doc(
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/m/.venvs/pythonenv/lib/python3.11/site-packages/googleapiclient/discovery.py", line 421, in _retrieve_discovery_doc
    raise UnknownApiNameOrVersion(
googleapiclient.errors.UnknownApiNameOrVersion: name: pollen  version: v1

Looking at https://developers.google.com/maps/documentation/pollen/reference/rest and comparing to other endpoints - attached script should work but unfortunately it isnt (error attached)
looks like library doesn't support it?!

@ohmayr
Copy link
Contributor

ohmayr commented Jun 18, 2024

Hi @MicZet, Thanks for reporting this issue.

The request fails because it's unable to find the pollen API in the cached directory: discovery cache.

As a workaround, you should be able to fetch the discovery document directly by setting static_discovery=False in the following way:

 service = build('pollen', version="v1", static_discovery=False)

This issue should be fixed once the artifacts are updated by the following PR #2419 and explicitly setting static_discovery=False won't be required once the discovery document for the API is available in the cached directory.

@MicZet
Copy link
Author

MicZet commented Jun 21, 2024

Thanks a lot @ohmayr
this steps succeed and return proper value

and btw in newest version i see endpoint is available.

@MicZet MicZet closed this as completed Jun 21, 2024
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

3 participants