These docs are for v3.0.2. Click to read the latest docs for v5.

Dynamic Execution

Call API

Execute an Injected Groovy Script

A simple REST api to dynamically execute a good script

curl --request POST \
  --url https://your_host_or_ip/api/call/execute/domainkey:apikey \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --data '{"sessionId":"uniqueid","code":"log.info(\"My injected code.\");"}'
var request = require("request");

var options = {
  method: 'POST',
  url: 'https://your_host_or_ip/api/call/execute/domainkey%3Aapikey',
  headers: {accept: 'application/json', 'content-type': 'application/json'},
  body: '{"sessionId":"uniqueid","code":"log.info(\"My injected code.\");"}'
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://your_host_or_ip/api/call/execute/domainkey%3Aapikey")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request.body = "{\"sessionId\":\"uniqueid\",\"code\":\"log.info(\\\"My injected code.\\\");\"}"

response = http.request(request)
puts response.read_body
var data = "{\"sessionId\":\"uniqueid\",\"code\":\"log.info(\\\"My injected code.\\\");\"}";

var xhr = new XMLHttpRequest();

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://your_host_or_ip/api/call/execute/domainkey%3Aapikey");
xhr.setRequestHeader("accept", "application/json");
xhr.setRequestHeader("content-type", "application/json");

xhr.send(data);
import requests

url = "https://your_host_or_ip/api/call/execute/domainkey%3Aapikey"

payload = "{\"sessionId\":\"uniqueid\",\"code\":\"log.info(\\\"My injected code.\\\");\"}"
headers = {
    'accept': "application/json",
    'content-type': "application/json"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)

Execute a Stored Template Script

This API is little more convenient as it doesn't require you to upload the script code every time you want to execute it, instead you can create a template scripts in the platform with a unique names (key) for each of them. Using this API you can dynamically merge the template with any dynamic arguments to the template as well as dynamic arguments to the script itself.