Implement Authentication Header in Simple Json

#1

Hello

I try to understand how the SimpleJson plugin works.
I need to pass an authentication header in my request, something like: "“Authorization”: "GenieKey ". My request is going to the Opsgenie Alert API: https://docs.opsgenie.com/docs/alert-api and I want to use that json as datasource. This is the url: https://api.opsgenie.com/v2/alerts But so far I keep getting errors about my headers. This is the error I get (it seems that my request is working properly but that it is blocked by a missing CROS header):


Is there any way to implement the nessecary headers properly? Or can I disable the CORS policy in SimpleJson?

#2

Please have a look at this which should explain how the simple json plugin works: Grafana simplejson dashboard

Seems to me you’re trying to use https://api.opsgenie.com/v2/alerts as the url when configuring simple json datasource. That don’t work. To use the simple json datasource you probably need to have a service in between which receives request from simple json datasource, do a request to https://api.opsgenie.com/v2/alerts and then translate and return a response that simple json datasource understands. The service in between is where you’ll put the logic for authenticating with opsgenie, like custom http headers.