Using AJAX plugin to make REST call

Hello,
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();
    xhttp.open("POST", "http://192.168.2.24:8080/rest/items/itm_all_off_fnt", true);
    xhttp.setRequestHeader("Content-type", "application/json");
    xhttp.send("OFF");
    var response = JSON.parse(xhttp.responseText);
}
</script>
<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.

image

This is the error:

image

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