You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the verbatim option in the species.name_usage method, I get an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/venv/lib/python3.8/site-packages/pygbif/species/name_usage.py", line 108, in name_usage
return name_usage_fetch(data, key, shortname, uuid, args, **kwargs)
File "/venv/lib/python3.8/site-packages/pygbif/species/name_usage.py", line 143, in name_usage_fetch
res = gbif_GET(url, args, **kwargs)
File "/venv/lib/python3.8/site-packages/pygbif/gbifutils.py", line 34, in gbif_GET
out.raise_for_status()
File "/venv/lib/python3.8/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.gbif.org/v1/species/5231190/verbatim?limit=100
Code to reproduce the error:
from pygbif import species
species.name_usage(key="5231190", data="verbatim")
However, when using the key for another taxon, it works:
from pygbif import species
species.name_usage(key="101683527", data="verbatim")
So, this issue seems to be on the API side. Still, this behavior is not documented.
The text was updated successfully, but these errors were encountered:
Since in Python, raising an exception is the most accepted way, I would suggest to throw a custom Exception that is more explanatory. When seeing the exception, I felt like I did something wrong.
GrazingScientist
changed the title
Option "verbatim" in method species.name_usage throws error for specieif taxon
Option "verbatim" in method species.name_usage throws error for specific taxon
Feb 23, 2023
Thank you for logging this issue and sorry for the late reply. You are right, we should include are custom exception explaining what the issues is in this case.
The issue is to do with the data itself. When you query a key in a checklist, then there is a verbatim value and the query is successful:
However, if you query a key from the GBIF taxonomic backbone (also technically a checklist, but the source GBIF use to interpret all the verbatim values we get from publishers), there is no verbatim value associated with the key (example below shows the backbone version of the same organism from the above example):
Python Version: 3.8
pygbif Version: 0.6.2
When using the
verbatim
option in the species.name_usage method, I get an error:Code to reproduce the error:
However, when using the key for another taxon, it works:
So, this issue seems to be on the API side. Still, this behavior is not documented.
The text was updated successfully, but these errors were encountered: