An API key is required for write requests

27 views
Skip to first unread message

Emiliano Heyns

unread,
Oct 9, 2024, 6:41:18 PMOct 9
to zotero-dev
I'm getting

An API key is required for write requests

when I issue

curl -v \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Zotero-Write-Token: $API_KEY" \
  -d '[{ "itemType": "journalArticle", "title": "title", "creators": [], "abstractNote": "", "publicationTitle": "", "volume": "", "issue": "", "pages": "", "date": "", "series": "", "seriesTitle": "", "seriesText": "", "journalAbbreviation": "", "language": "", "DOI": "", "ISSN": "", "shortTitle": "", "url": "", "accessDate": "", "archive": "", "archiveLocation": "", "libraryCatalog": "", "callNumber": "", "rights": "", "extra": "", "tags": [], "collections": [], "relations": {} } ]' \
  https://api.zotero.org/users/111111/collections/X3H3DPLJ/items

I've checked the API URL and the API_KEY (has full access). Any idea what I am doing wrong?

Tomasz Najdek

unread,
Oct 9, 2024, 7:24:55 PMOct 9
to zoter...@googlegroups.com
Shouldn't it be "Zotero-API-Key" instead of "Zotero-Write-Token"?
--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zotero-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/zotero-dev/e6af122e-e814-4d20-8aa2-6152eae9d486n%40googlegroups.com.

Emiliano Heyns

unread,
Oct 10, 2024, 1:50:15 AMOct 10
to zotero-dev
I've tried that too with the same result, but Zotero-Write-Token is what the docs say under Creating an Item: https://www.zotero.org/support/dev/web_api/v3/write_requests

You received this message because you are subscribed to a topic in the Google Groups "zotero-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/zotero-dev/yVgJJ4mCm-I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to zotero-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/zotero-dev/fTawvQJ1j025V_FWRs4XQybb5vCj9zVNrsOmR4KmKG4oJcmCA9LTKC_H_WkNhv86Md-HxJZY-0ukCTu0bP8mxQw3k7RrG80_seY2Xhwsipc%3D%40doppnet.com.

Dan Stillman

unread,
Oct 10, 2024, 1:54:16 AMOct 10
to zoter...@googlegroups.com
No, Zotero-Write-Token is an old, rarely used header, described here:

https://www.zotero.org/support/dev/web_api/v3/write_requests#zotero-write-token

You'd only use that if you're not using versioning, which was added later and which is the standard way of using the API.

The API key goes in Zotero-API-Key, described here:

https://www.zotero.org/support/dev/web_api/v3/basics#authentication


On 10/10/24 1:50 AM, Emiliano Heyns wrote:

Emiliano Heyns

unread,
Oct 10, 2024, 2:39:12 AMOct 10
to zotero-dev
Right, and then I get the same error. 

--
You received this message because you are subscribed to a topic in the Google Groups "zotero-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/zotero-dev/yVgJJ4mCm-I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to zotero-dev+...@googlegroups.com.

Dan Stillman

unread,
Oct 10, 2024, 2:47:21 AMOct 10
to zoter...@googlegroups.com
Then it's not a valid API key or you're trying to access something the key doesn't have access to.


On 10/10/24 2:38 AM, Emiliano Heyns wrote:

Dan Stillman

unread,
Oct 10, 2024, 2:53:34 AMOct 10
to zoter...@googlegroups.com
Well, if it still says "An API key is required for write requests", you're doing something wrong and the right header isn't actually getting sent.

If you're getting a different error, it would depend on what the error says.

Dan Stillman

unread,
Oct 10, 2024, 2:55:56 AMOct 10
to zoter...@googlegroups.com
Oh, and your URL is wrong. That's a collection-items URL. That's not the endpoint for creating new items.

Emiliano Heyns

unread,
Oct 10, 2024, 3:01:08 AMOct 10
to zotero-dev
That was an edit error, apologies; in my actual tests it has /items.

Is there anyone I can send the real user ID (not present above), real collection key (not present above) and the API key to to verify? I'm still getting the same error.

Dan Stillman

unread,
Oct 10, 2024, 3:04:22 AMOct 10
to zoter...@googlegroups.com
You can just send the userID to sup...@zotero.org to start, but there's no collection key… If you're including a collection key in the URL when creating an item, your URL is wrong.

Emiliano Heyns

unread,
Oct 10, 2024, 3:27:14 AMOct 10
to zotero-dev
Ah, *that* is the problem, thank you! I need to create it, *then* add it to a collection.

Dan Stillman

unread,
Oct 10, 2024, 3:31:23 AMOct 10
to zoter...@googlegroups.com
No, you can pass a collection key in the item data when you create the item.

Emiliano Heyns

unread,
Oct 10, 2024, 3:44:44 AMOct 10
to zotero-dev
Right you are, that is in the sample.
Reply all
Reply to author
Forward
0 new messages