I just installed simple-json plugin and it appears as a potential data source.
Using Postman I was able to check request and response based on examples from https://github.com/grafana/simple-json-datasource.
However, there is an error in the request example as:
400 Bad Request
Bad Request
Failed to decode JSON object: Expecting property name enclosed in double quotes: line 18 column 30 (char 322)
This seems to be due to missing “” for refId as when it is manually converted to “refId” it works at Postman.
I am using 1.3.1
My question is if json plugin request is exactly the same as request example or not.
As in the example request the “” is missing for refId and in my test environment it doesnt work.
Here is what I get from Postman test environment compared to Grafana datasource.
1- Postman test:
Request example from website IS EDITED by adding “” to refId
And I get the right response which I check my response in https://jsonlint.com/ and it says it is a valid json.
If “” is not added it throughs:
400 Bad Request
Bad Request
Failed to decode JSON object: Expecting property name enclosed in double quotes: line 18 column 30 (char 322)
2- Grafana:
I add the url by having updated json plugin.
On Grafana I get “Unknown error"
on terminal I get
"GET /query/ HTTP/1.1” 404 -
Thats why I am assuming there is sth wrong with request from json plugin and most probably it is the missing “”.
Where is it missing? No on else has had this issue with the data source so its pretty strange. Sounds more like a problem with your http server returning non valid json
Sorry, totally missed that you meant the example. Thought you meant that Grafana was not returning valid JSON. I will update the example straight away. Thanks for clearing up the confusion!
no worries, my bad as I was not clear enough.
I am sure that I return expected json for plugin and tested through postman too.
When data source is added to grafana it gives unknown error.
Any idea why it happens ?
I found error in console as:
No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://grafana.staged-by-discourse.com’ is therefore not allowed access. The response had HTTP status code 404.
This is the classic CORS (cross origin) error. It is a security feature built into the browser which does not allow http requests between different domains and localhost with different ports are considered different domains. So foobar:3000 and foobar:4000 are the same domain and would not return an error but community.grafana.com and localhost:4000 are considered different domains.