0

I wold like to send an HTTP request from within a script task in a BPMN model executed by Camunda using Javascript. Does anyone know how to do that?

I've already tested this:

var xmlhttp;
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "http://test.local/append.php", true);
xmlhttp.send();

But once I get to the script task containing the above code, Tasklist prompts that XMLHttpRequest is not found.

Mehran
  • 15,593
  • 27
  • 122
  • 221
  • Is your Javascript code server-side? If so, `XMLHttpRequest` is unavailable in your case; it only exists in browsers – hindmost Aug 10 '15 at 08:35
  • The javascript code above is executed by Java run time. To be honest it's my first time experiencing it myself. It surely is not executed in a browser environment but I'm not sure if it is the same as running it as a server-side code! How can I make an Ajax call in a server-side javascript? I can test it and see if it works. – Mehran Aug 10 '15 at 09:08

1 Answers1

1

Depending on your Java version you either use the Rhino (until Java 7) or Nashorn (since Java 8) Javascript engine. Both have no concept of XmlHttpRequest as you know it from Javascript engines in web browsers. So you have to use a library which allows you to send HTTP Requests. This Post links a XmlHttpRequest implementation for Rhino.