urschrei / pyzotero

Pyzotero: a Python client for the Zotero API
https://pyzotero.readthedocs.org
Other
908 stars 99 forks source link

Create an item as a child of an existing collection #116

Closed bein7 closed 4 years ago

bein7 commented 4 years ago

General

If at all possible, provide a MVCE. If this is inappropriate (e.g. it's obviously a bug), just fill in the below:

Platform:
Python version: 3.7 Pyzotero version:

Problem description

If possible, paste the full traceback in a code block below, and fill in the summary

Traceback new_item = [{ 'itemType': "book", 'title': "Test du vendredi", } ] zot.create_items(new_item, "C5U3MI63") code goes here, indented with four spaces
urschrei commented 4 years ago

Your example code creates a child item, it does not add an item to a collection.

You haven't specified what C5U3MI63 is – is it a collection ID?

If it's a collection ID, you would have to do this instead:

new_item = [{ 'itemType': "book", 'title': "Test du vendredi", } ]
result = zot.create_items(new_item)
zot.addto_collection("C5U3MI63", result[0])
bein7 commented 4 years ago

Yes. Thanks. I thought a child item means an item added to a collection.