# Troubleshooting JSON:API / JupyterLite

**URL:** <https://farmos.discourse.group/t/troubleshooting-json-api-jupyterlite/1184>\
**Category:** Hosting farmOS\
**Created:** [March 22, 2022, 5:29pm UTC](https://farmos.discourse.group/t/troubleshooting-json-api-jupyterlite/1184 "2022-03-22T17:29:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Farmy](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@Farmy](https://farmos.discourse.group/u/Farmy)\
**Post date:** [March 22, 2022, 5:29pm UTC](https://farmos.discourse.group/t/troubleshooting-json-api-jupyterlite/1184/1 "2022-03-22T17:29:19Z")

</div>

Continuing the troubleshooting discussion from [Share your JupyterLite Examples](https://farmos.discourse.group/t/share-your-jupyterlite-examples/1134):

**Issue:** Executing the JupyterLite example “animal\_csv\_import.ipynb” causes an  
_OSError: Request for [https://localhost/api/taxonomy\_term/animal\_type](https://localhost/api/taxonomy_term/animal_type) failed with status 500: 500 Service unavailable (with message)_

---

<div class="post-metadata">

**Author:** ![Farmy](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@Farmy](https://farmos.discourse.group/u/Farmy)\
**Post date:** [March 22, 2022, 5:43pm UTC](https://farmos.discourse.group/t/troubleshooting-json-api-jupyterlite/1184/2 "2022-03-22T17:43:31Z")

</div>

The traceback log of “animal\_csv\_import.ipynb” in JupyterLite reports a failure in /lib/python3.9 (the Pyolite kernel of JupyterLite?), but a few lines below there is a reference to python 3.8 which is my default python installation. Is there a conflict?

```auto
File /lib/python3.9/site-packages/pyodide/http.py:139, in FetchResponse.json(self, **kwargs)
    133 async def json(self, **kwargs) -> Any:
    134 """Return the response body as a Javascript JSON object.
    135 
    136 Any keyword arguments are passed to `json.loads
    137 <https://docs.python.org/3.8/library/json.html#json.loads>`_.
    138 """
--> 139 self._raise_if_failed()

```

---

<div class="post-metadata">

**Author:** ![Farmy](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@Farmy](https://farmos.discourse.group/u/Farmy)\
**Post date:** [March 22, 2022, 8:57pm UTC](https://farmos.discourse.group/t/troubleshooting-json-api-jupyterlite/1184/3 "2022-03-22T20:57:50Z")

</div>

@Symbioquine I’m one step further now. If I remove the bold part below from the HTTP request, then it works. Do you have an idea what the root cause might be?

curl -k ‘[https://localhost/api/taxonomy\_term/animal\_type](https://localhost/api/taxonomy_term/animal_type)’ -X POST -H ‘User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86\_64; rv:98.0) Gecko/20100101 Firefox/98.0’ -H ‘Accept: _/_’ -H ‘Accept-Language: de,en-US;q=0.7,en;q=0.3’ -H ‘Accept-Encoding: gzip, deflate, br’ -H ‘Referer: [https://localhost/jupyterlite/lab/index.html](https://localhost/jupyterlite/lab/index.html)’ -H ‘Content-type: application/vnd.api+json’ -H ‘X-CSRF-Token: —OMITTED—’ _**-H ‘Origin: [https://localhost](https://localhost)’ -H ‘Connection: keep-alive’ -H ‘Cookie: —OMITTED—; jupyterliteDrupalBasePath=/’ -H ‘Sec-Fetch-Dest: empty’ -H ‘Sec-Fetch-Mode: cors’ -H 'Sec-Fetch-Site: same-origin’**_ --data-raw ‘{“data”: {“type”: “taxonomy\_term–animal\_type”, “attributes”: {“name”: “Sheep”}}}’

---

<div class="post-metadata">

**Author:** ![Symbioquine](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/symbioquine/32/284_2.png) [@Symbioquine](https://farmos.discourse.group/u/Symbioquine)\
**Post date:** [March 23, 2022, 2:20am UTC](https://farmos.discourse.group/t/troubleshooting-json-api-jupyterlite/1184/4 "2022-03-23T02:20:49Z")

</div>

I don’t see anything obviously wrong. That’s an interesting clue about removing those headers, but I don’t have a ready hypothesis about why those would be a problem. I just checked and my requests (which are working) also include similar headers to those.

Are you willing to share your NGINX reverse proxy configuration?

---

<div class="post-metadata">

**Author:** ![Farmy](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@Farmy](https://farmos.discourse.group/u/Farmy)\
**Post date:** [March 23, 2022, 2:50pm UTC](https://farmos.discourse.group/t/troubleshooting-json-api-jupyterlite/1184/5 "2022-03-23T14:50:46Z")

</div>

@Symbioquine I’m curious. Here is the nginx.conf :

```auto
events {}
http {
  server {
      listen 80 default_server;
      listen [::]:80 default_server;
      server_name _;
      return 301 https://$host$request_uri;
  }
  server {
    server_name localhost;
    listen 443 ssl;
    ssl_certificate /etc/nginx/ssl/openssl.crt;
    ssl_certificate_key /etc/nginx/ssl/openssl.key;
    location / {
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-Host $http_host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_buffer_size 128k;
      proxy_buffers 4 256k;
      proxy_busy_buffers_size 256k;
      proxy_pass http://www;
    }
  }
}

```

I followed exactly the description of configuring Local HTTPS here:

> **[Local HTTPS](https://farmos.org/development/environment/https/)**
>
> farmOS is a free and open source web-based application for farm management, planning, and record keeping.

---

<div class="post-metadata">

**Author:** ![Farmy](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@Farmy](https://farmos.discourse.group/u/Farmy)\
**Post date:** [March 23, 2022, 4:00pm UTC](https://farmos.discourse.group/t/troubleshooting-json-api-jupyterlite/1184/6 "2022-03-23T16:00:18Z")

</div>

I removed SSL / HTTPS. No change. ☹

---

<div class="post-metadata">

**Author:** ![Farmy](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@Farmy](https://farmos.discourse.group/u/Farmy)\
**Post date:** [March 25, 2022, 8:31pm UTC](https://farmos.discourse.group/t/troubleshooting-json-api-jupyterlite/1184/7 "2022-03-25T20:31:13Z")

</div>

Problem solved! 🙂  
Solution: JSON API resp. JupyterLite can be used only, if no user is concurrently logged in in FarmOS.

---

<div class="post-metadata">

**Author:** ![Symbioquine](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/symbioquine/32/284_2.png) [@Symbioquine](https://farmos.discourse.group/u/Symbioquine)\
**Post date:** [March 26, 2022, 2:09am UTC](https://farmos.discourse.group/t/troubleshooting-json-api-jupyterlite/1184/8 "2022-03-26T02:09:26Z")

</div>

> Solution: JSON API resp. JupyterLite can be used only, if no user is concurrently logged in in FarmOS.

Hmmm, that’s strange. I just did a bit of testing and I can’t reproduce that behavior. (I tested with multiple separate users and the same user from a separate browser session while re-running the example in JupyterLite which retrieves/creates the animal taxonomy - it worked every time.)
