Error pdf download by API

from pyzotero import zotero

library_id = '...' # personal library ID
library_type = 'user' # Accessing your own Zotero library
api_key = '...' # API key from the Zotero site

zot = zotero.Zotero(library_id, library_type, api_key)

itmKey = items[0]['data']['key']

zot.file(itmKey)


HTTPError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/pyzotero/zotero.py in _retrieve_data(self, request, params)
425 try:
--> 426 self.request.raise_for_status()
427 except requests.exceptions.HTTPError as exc:

4 frames
/usr/local/lib/python3.10/dist-packages/requests/models.py in raise_for_status(self)
1020 if http_error_msg:
-> 1021 raise HTTPError(http_error_msg, response=self)
1022

HTTPError: 400 Client Error: Bad Request for url: https://api.zotero.org/users/.../items/.../file

The above exception was the direct cause of the following exception:

UnsupportedParams Traceback (most recent call last)
in ()
----> 1 zot.file(itmKey)

/usr/local/lib/python3.10/dist-packages/pyzotero/zotero.py in wrapped_f(self, *args, **kwargs)
177 if kwargs:
178 self.add_parameters(**kwargs)
--> 179 retrieved = self._retrieve_data(func(self, *args))
180 # we now always have links in the header response
181 self.links = self._extract_links()

/usr/local/lib/python3.10/dist-packages/pyzotero/zotero.py in _retrieve_data(self, request, params)
426 self.request.raise_for_status()
427 except requests.exceptions.HTTPError as exc:
--> 428 error_handler(self, self.request, exc)
429 backoff = self.request.headers.get("backoff") or self.request.headers.get(
430 "retry-after"

/usr/local/lib/python3.10/dist-packages/pyzotero/zotero.py in error_handler(zot, req, exc)
1658 raise error_codes.get(req.status_code)(err_msg(req))
1659 else:
-> 1660 raise error_codes.get(req.status_code)(err_msg(req)) from exc
1661 else:
1662 if not exc:

UnsupportedParams:
Code: 400
URL: https://api.zotero.org/users/.../items/.../file
Method: GET
Response: Item is not an attachment
  • edited November 21, 2023
    Technical questions should be posted to zotero-dev, though be aware that pyzotero is a third-party project, so you'd be better off asking them. It looks like the message just means what it says, though — you're trying to make a file request on an item that's not a file.
Sign In or Register to comment.