# Local API: new item with a client-supplied key fails with "'primaryData' not loaded"

Zotero 10.0.3 on Windows 11, local API writes enabled with a persistent key.

`POST /api/users/0/items` with new items that include a `key` and `"version": 0`,
as the Web API syncing docs describe for new objects with predetermined keys,
returns 200 with every object under `failed`:

```json
{"key": "RZRUVEDZ", "code": 400, "message": "'primaryData' not loaded for item (null/1/RZRUVEDZ)"}
```

A child note in the same request then fails with
`Parent item 1/RWU6U8MS not found`.

The items came unchanged from translation-server's `/search` for DOIs such as
10.1214/17-aoas1092 and 10.57805/revstat.v10i1.110, sent with pyzotero 1.15.2
`create_items`. Sending `If-Unmodified-Since-Version` with `version` omitted
fails the same way.

In `server_localAPI.js`, the POST handler reaches `makeNewObjectWithKey()`
for a key with no database row. That function sets `obj.key` and calls
`obj.loadPrimaryData()` before `fromJSON()`, and the error suggests the
primary data stays unloaded for a key that doesn't exist yet.

The expected result is a new item under the key in the request, as on the Web API.
Sign In or Register to comment.