BookOps-CAT / bookops-worldcat

BookOps WorldCat Metadata API wrapper
https://bookops-cat.github.io/bookops-worldcat/
MIT License
35 stars 7 forks source link

Get current holdings sample code question #95

Closed HXyL229ZI0gk5u closed 5 months ago

HXyL229ZI0gk5u commented 6 months ago

I find that the holdings_get_current sample code (https://bookops-cat.github.io/bookops-worldcat/latest/manage_holdings/) only returns the following error, unless the OCLC number is enclosed in quotes:

Traceback (most recent call last): File "C:\Users\tosaka\PycharmProjects\DataSync2\main.py", line 20, in response = session.holdings_get_current(oclcNumbers=123456789) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\tosaka\Anaconda3\envs\pythonProject\Lib\site-packages\bookops_worldcat\metadata_api.py", line 879, in holdings_get_current vetted_numbers = verify_oclc_numbers(oclcNumbers) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\tosaka\Anaconda3\envs\pythonProject\Lib\site-packages\bookops_worldcat\utils.py", line 84, in verify_oclc_numbers raise InvalidOclcNumber( bookops_worldcat.errors.InvalidOclcNumber: Argument 'oclcNumbers' must be a list or comma separated string of valid OCLC #s.

HXyL229ZI0gk5u commented 6 months ago

Putting in brackets and making a list seems to return the output as expected:

response = session.holdings_get_current(oclcNumbers=[123456789])

charlottekostelic commented 6 months ago

@HXyL229ZI0gk5u, thank you! We will include a fix in 1.0.1 to allow a single int to be passed as an arg to holdings_get_current and bib_get_current_oclc_number.