Zotero API, text/plain response & encoding

52 views
Skip to first unread message

Frank Bennett

unread,
Aug 30, 2023, 8:15:31 PM8/30/23
to zotero-dev
I'm having some trouble fetching a plain text file from the Zotero API. I'm consistently getting a binary blob that doesn't conform to the expected encoding. I'm not sure what I'm doing wrong. Here are the steps:

1. The file is set as an attachment via the JS Console, using Zotero.Attachments.importFromFile(), declaring "text/plain" as the contentType, and "utf-8" or "windows-1252" as the charset (with a file converted to the declared encoding).

2. Double-clicking on the attachment in the client pops up a view of the file content with numbered lines. Everything seems to be in order.

3. After sync, and after parsing some sync transactions to identify the attachment ID, I'm making an authenticated GET request:

    GET https://api.zotero.org/groups/<libraryID>/items/<attachmentID>/file

4. The server response reports the contentType and charset declared to the local client when importing the file, so that information is reaching the server.

5. The response.text returned by the server is a binary blob that is neither UTF-8 nor windows-1252.

PDF and RTF files are processing correctly. I'm only having this problem with plain text attachments.

Grateful for any suggestions on what I might be doing wrong.

Frank

Dan Stillman

unread,
Aug 31, 2023, 1:14:15 AM8/31/23
to zoter...@googlegroups.com
On 8/30/23 8:15 PM, Frank Bennett wrote:
> I'm having some trouble fetching a plain text file from the Zotero
> API. I'm consistently getting a binary blob that doesn't conform to
> the expected encoding.

I assume if you delete the file locally (Show File → delete),
redownloading the file by double-clicking on the attachment works properly?

Can you provide a Debug ID for that? (If this is Jurism and you can't
provide a Debug ID, you can email debug output to sup...@zotero.org.)
Reply all
Reply to author
Forward
Message has been deleted
0 new messages