On 2/20/20 1:26 AM, Frank Bennett wrote:
> I've gotten slightly confused in the docs re deleting items via the
> Zotero API, and I'd like to confirm that I understand things correctly:
>
>
https://www.zotero.org/support/dev/web_api/v3/write_requests#deleting_multiple_items
>
> Testing with a single item, I fetched the attachment metadata, pulled
> out the item key and version, and fed that back to a DELETE request.
> The request failed with a 412 error ("The library has changed since
> the specified version"). As options to the call:
>
> // ?itemKey=43BYNQ7L
> // maxVersion: 2505
> {
> "method": "DELETE",
> "headers": {
> "content-type": "application/json",
> "Zotero-API-Key": "...",
> "If-Unmodified-Since-Version": "2505"
> },
> "url": "?itemKey=43BYNQ7L",
> "baseURL": "
https://api.zotero.org/groups/2318535/items/",
> "responseType": "json"
> }
> Error: Request failed with status code 412
>
> […]
>
> So what I _think_ this may mean is that the modification threshold
> value is the version of the immediate container? So for a top-level
> item, that would be the containing library ("5" in this case); and for
> an attachment, it would be the parent item serving as its "container."
>
> Is that a correct read on the behavior?
No, nothing to do with the parent item.
It sounds like you're passing the item version to the multi-object
DELETE request instead of the library version.
For single-object requests,
Last-Modified-Version/If-Unmodified-Since-Version are for the version of
the object. For multi-object requests, they apply to the library as a
whole. (That's why the error message says that the library has changed
since the specified version, not that the item has changed.) The fact
that you're passing only a single item key to a multi-item endpoint is
immaterial.
The various version properties are explained in detail on the Syncing
page [1], but I'll see if I can clarify things on the Write Requests page.
[1]
https://www.zotero.org/support/dev/web_api/v3/syncing#version_numbers