# JSON API Data Source : 404 error

**URL:** <https://community.grafana.com/t/json-api-data-source-404-error/89852>\
**Category:** Data Links\
**Tags:** json, json-api-datasource\
**Created:** [June 19, 2023, 8:03am UTC](https://community.grafana.com/t/json-api-data-source-404-error/89852 "2023-06-19T08:03:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brettbeeson](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@brettbeeson](https://community.grafana.com/u/brettbeeson)\
**Post date:** [June 19, 2023, 8:03am UTC](https://community.grafana.com/t/json-api-data-source-404-error/89852/1 "2023-06-19T08:03:16Z")

</div>

Greetings humans! I have a simple task: read an JSON API on another server and display the data in Grafana.

In the three images I do the following on a Grafana instance at, say, [https://mygrafanaserver.com/](https://mygrafanaserver.com/).

1. Install JSON API and set the URL (e.g. [http://coolapi.com/api/v1/](http://coolapi.com/api/v1/)). API is on a different server.
2. Create a panel and specify that datasource. I expect it to read [http://coolapi.com/api/v1/devices](http://coolapi.com/api/v1/devices). I set the fields to (e.g.) “name”. Go! But the response is from my Grafana server (all that html guff), not [coolapi.com](http://coolapi.com)
3. I check ‘network’ and see, yes, it’s requesting [https://mygrafanaserver/api/v1](https://mygrafanaserver/api/v1).

I’m clearly an idiot: where am I going wrong?

Thanks!

ps. I must misunderstannd dataproxy as I expect the browser to ask /dataproxy/uid/… to make this request (i.e. from Grafana backend). But I see the request to the API in the browser.

pps. I’ve also tried checking CORS, different JSON datasources (infinity), removing auth p(I use a Token auth, but I think it’s not related)

Step 1

 ![1-data](https://us1.discourse-cdn.com/grafana/original/3X/8/c/8cafdb720b24f4201a6f1d83cc6b1229821a27cc.png)  
Step 2  
 ![2-panel](https://us1.discourse-cdn.com/grafana/original/3X/3/0/30649737bd1ddb7b542af357f75d8937a466427a.jpeg)  
Step 3  
 ![3.network](https://us1.discourse-cdn.com/grafana/original/3X/a/3/a31da54bef4081451cd9ff276fac1bcda6ce73a3.png)

---

<div class="post-metadata">

**Author:** ![brettbeeson](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@brettbeeson](https://community.grafana.com/u/brettbeeson)\
**Post date:** [June 19, 2023, 11:59pm UTC](https://community.grafana.com/t/json-api-data-source-404-error/89852/2 "2023-06-19T23:59:20Z")

</div>

Forgot to add: Grafana Version 9.5.3 (commit: 916d9793aa, branch: HEAD)

---

<div class="post-metadata">

**Author:** ![brettbeeson](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@brettbeeson](https://community.grafana.com/u/brettbeeson)\
**Post date:** [June 21, 2023, 7:01am UTC](https://community.grafana.com/t/json-api-data-source-404-error/89852/3 "2023-06-21T07:01:16Z")

</div>

It’s a slash. Yeah, that’s right:

- `/api/cool/device/1/` OK
- `/api/cool/device/1` FAIL

I don’t know the whole story, but note

- It’s a NGINX related thing: NGINX is proxy\_pass and returning a 301 redirect to a URL with the slash. [Reference](https://stackoverflow.com/questions/53787116/why-is-my-nginx-reverse-proxy-doing-a-301-redirect-instead-of-proxying)
- Postman works fine on the API. I guess it can handle the 301 and re-request. The JSON datasource, I guess, doesn’t do this.
- The difficult to work out error messages are (guessing) related to dataproxy in Grafana displaying a 404, when it actually received a 301 from the API. Other errors (e.g. 500) from the server are also shown as 404.

**The simple solution is to add a trailing slash to queries, so NGINX doesn’t send a 301.**

( A better solution would be to stop ngnix adding the slash. That’s homework.)
