Zotero Integration error: Error retrieving item data: Unexpected end of JSON input

What I’m trying to do

Hello,

I’m having an issue with the Zotero Integration since a few days. This issue only comes up with my laptop (Surface Pro 6, Windows 11 Pro, V.22H2), while everything works fine with my desktop at work. In both cases, Obsidian, the Zotero Integration plugin and the better BibTex add-on in Zotero are up-to-date.

Basically, when I try importing Zotero data to create a litterature note in Obsidian, I receive the following error message:

Error retrieving item data: Unexpected end of JSON input

I have checked the console, and there are two issues:

One Syntax error:

In plugin:obsidian-zotero-desktop-connector:98

SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at nr (plugin:obsidian-zotero-desktop-connector:98:8531)
at async Ep (plugin:obsidian-zotero-desktop-connector:112:2121)
at async Object.callback (plugin:obsidian-zotero-desktop-connector:118:313955)
nr @ plugin:obsidian-zotero-desktop-connector:98

And a (in promise) TypeError:

In plugin:obsidian-zotero-desktop-connector:112

Uncaught (in promise) TypeError: Cannot read properties of null (reading ‘length’)
at Ep (plugin:obsidian-zotero-desktop-connector:112:2180)
at async Object.callback (plugin:obsidian-zotero-desktop-connector:118:313955)

What should I do?

I have tried to re-install the plugin and better BibTex, but nothing is working so far. I’m not super tech-savy so I don’t really understand these error messages.

Thank you for your help!

1 Like

This seems like something template related. Can you share your template?

Below you can find my template. But as mentioned in my initial post, the importation works fine on another computer. Thanks!

Below is the template (1/2, Had to cut it in half because the forum won’t let me send a post with >5 links)

EDIT: also forgot to mention it but it used to work just fine before.


citekey: {{citekey}}
aliases: ["
{%- if creators -%}
{{creators[0].lastName}}
{%- if creators|length > 1 %} et al.{% endif -%}
{%- endif -%}
{%- if date %} ({{date | format(“YYYY”)}}){% endif -%}
{%- if shortTitle %} {{shortTitle | safe}} {%- else %} {{title | safe}} {%- endif -%}
"]
title: “{{title}}”
authors: {{authors}}
tags: [{% for t in tags %}{{t.tag}}{% if not loop.last %}, {% endif %}{% endfor %}]
year: {{date | format(“YYYY”)}}
publisher: “{{publicationTitle}}”
doi: {{DOI}}
Note-category: literature-note

{{title}}

{% persist “notes” %}
{% if isFirstImport %}

Key takeaways

  • <% tp.file.cursor(1) %>

Processing

  • Connections:: <% tp.file.cursor(2) %>
  • Status:: <% tp.file.cursor(3) %>
    {% endif %}{% endpersist %}

[!info]- Info - Zotero | DOI | {% for attachment in attachments | filterby(“path”, “endswith”, “.pdf”) %}[PDF](file:///{{attachment.path | replace(" ", “%20”)}}){%- endfor %}

{% if bibliography %}Bibliography: {{bibliography|replace(“\n”," ")}}{% endif %}

Authors:: {% for a in creators %} [[{{a.firstName}} {{a.lastName}}]]{% if not loop.last %}, {% endif %}{% endfor %}

{% if hashTags %}Tags: {{hashTags}}{% endif %}

Collections:: {% for collection in collections %}[[{{collection.name}}]]{% if not loop.last %}, {% endif %}{% endfor %}

First-page: {% for annotation in annotations %}{% if loop.first %}{{annotation.pageLabel}}{% endif %}{% endfor %}

[!abstract]-
{% if abstractNote %}
{{abstractNote|replace(“\n”," ")|striptags(true)|replace(“Objectives”, “Objectives”)|replace(“Background”, “Background”)|replace(“Methodology”, “Methodology”)|replace(“Results”,“Results”)|replace(“Conclusion”,“Conclusion”)}}
{% endif %}


Reading Annotations

{% macro heading(color) -%}
{%- if color == “#5fb236” -%}
:bulb: Main ideas and conclusions
{%- endif -%}
{%- if color == “#2ea8e5” -%}
:grey_question: Questions
{%- endif -%}
{%- if color == “#ffd400” -%}
:star: Important
{%- endif -%}
{%- if color == “#a28ae5” -%}
:jigsaw: Definitions and concepts
{%- endif -%}
{%- if color == “#ff6666” -%}
:no_entry: Weaknesses and caveats
{%- endif -%}
{%- if color == “#e56eee” -%}
:zap: Background
{%- endif -%}
{%- if color == “#f19837” -%}
:gear: Method
{%- endif -%}
{%- if color == “#aaaaaa” -%}
:mega: To research further
{%- endif -%}
{%- endmacro -%}

{% macro calloutCharacter(color) -%}
{%- if color == “#5fb236” -%}
$
{%- endif -%}
{%- if color == “#2ea8e5” -%}
@
{%- endif -%}
{%- if color == “#ffd400” -%}
&
{%- endif -%}
{%- if color == “#a28ae5” -%}
~
{%- endif -%}
{%- if color == “#ff6666” -%}
!
{%- endif -%}
{%- if color == “#e56eee” -%}

{%- endif -%}
{%- if color == “#f19837” -%}
?
{%- endif -%}
{%- if color == “#aaaaaa” -%}
%
{%- endif -%}
{%- endmacro -%}

{% persist “annotations” %}
{% set annotations = annotations | filterby(“date”, “dateafter”, lastImportDate) -%}
{% if annotations.length > 0 %}
Imported on {{importDate | format(“YYYY-MM-DD HH:mm”)}}

{% for color, annotations in annotations | groupby(“color”) -%}

(2/2)

{{heading(color)}}

{% for annotation in annotations -%}
{%- if annotation.imageRelativePath %}

[!cite]+ Image (p. {{annotation.pageLabel}})
![[{{annotation.imageRelativePath}}]]{% if annotation.hashTags %}
{{annotation.hashTags}}{% endif %}{%- if (annotation.comment or ).indexOf("todo ") !== -1 %}

  • {{annotation.comment | replace("todo ", “”)}}{% else %}
    {{annotation.comment}}{%- endif -%}

{% elif (annotation.comment or ).indexOf("todo ") !== -1 %}

  • {{annotation.comment | replace("todo ", “”)}}:{% if not annotation.annotatedText %} (p. {{annotation.pageLabel}}){% else %}
    • {{calloutCharacter(annotation.color)}} {{annotation.annotatedText | nl2br}} (p. {{annotation.pageLabel}}) {% if annotation.hashTags %}{{annotation.hashTags}}{% endif -%}{% endif -%}
      {% elif annotation.comment %}
  • {{annotation.comment}}:{% if not annotation.annotatedText %} (p. {{annotation.pageLabel}}){% else %}
    • {{calloutCharacter(annotation.color)}} {{annotation.annotatedText | nl2br}} (p. {{annotation.pageLabel}}) {% if annotation.hashTags %}{{annotation.hashTags}}{% endif -%}{% endif %}
      {%- elif annotation.annotatedText %}
  • {{calloutCharacter(annotation.color)}} {{annotation.annotatedText | nl2br}} (p. {{annotation.pageLabel}})](zotero://open-pdf/library/items/{{annotation.attachment.itemKey}}?page={{annotation.pageLabel}}&annotation={{annotation.id}}) {% if annotation.hashTags %}{{annotation.hashTags}}{% endif %}
    %had to break this last link to post%
    {%- endif -%}{%- endfor %}

{% endfor -%}
{% endif %}
{% endpersist %}

Hi,

Just ran into the same problem.
Seems as if BetterBibTeX > v6.7.140 causes the issue.
There’s a very recent open issue at github

4 Likes

Thanks! I had tried to install the previous BetterBibTex Zotero addon (V.6.7.142) but it did not work so I had ruled this out.

It works now.

You can install V6.7.140 and it will solve the problem (may be better to turn-off add-on update automatically in zotero at least temporarily.)

3 Likes

This issue is closed on github. So instead of downgrading better bitex, upgrading to the latest zotero integration plugin (3.1.7) fixed it for me.

1 Like

Yeah, Zotero Integration got an update (3.1.5) that addresses the Better Bibtex API change, which broke it.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.