Using AJAX plugin to make REST call

I’m trying to use the AJAX plugin for Grafana to create a button that makes a REST call. The REST call is to my home automation system (OpenHAB).

I’m basically trying to replicate this javascript function inside the AJAX plugin:

<script type="text/javascript" language="javascript">
function UserAction() {
    var xhttp = new XMLHttpRequest();"POST", "", true);
    xhttp.setRequestHeader("Content-type", "application/json");
    var response = JSON.parse(xhttp.responseText);
<button type="submit" onclick="UserAction()">Clickme</button>

But I’m not sure how to fill in the fields. This was my best guess, and I’m getting errors. I think it’s because I don’t know how to form the parameters_js.


This is the error:


Did you ever work this out? I am running into similar issues trying to use the AJAX component to call API’s

use the Display:Mode Angular Template and then you can paste your js script and html button there…