What is the best way to call REST API from Activiti? Can I use JavaScript's URL redirection?

I am relatively new to Activiti. My question has to be one of the common ones (but I haven't found an answer by Googling):

What is the best way to REST API from Activiti? I chose to use JavaScript's URL redirection logic: <scriptTask id="call_remote_biit" name="Trigger Biit Calc" activiti:autoStoreVariables="false"> <script>window.location.href = "http://remote_rest_call/?key=val";</script> </scriptTask>

FYI - I don't need to get the return code from the remote service. All I want to do is to trigger some event which will be tracked separately.

Tijs when I tried to use XMLHttpRequest in script task than it was giving below error, can you please explain how to fix it?

Caused by: org.activiti.engine.ActivitiException: problem evaluating script: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "XMLHttpRequest" is not defined. (<Unknown source>#1) in <Unknown source> at line number 1 at org.activiti.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:89) at org.activiti.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:73) at org.activiti.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior.execute(ScriptTaskActivityBehavior.java:63) at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:60) at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:631) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626) at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:52) at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56) at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:631) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626) at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49) at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:631) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626) at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:49) at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:631) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626) at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake.execute(AtomicOperationTransitionNotifyListenerTake.java:80) at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:631) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626) at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionDestroyScope.execute(AtomicOperationTransitionDestroyScope.java:116) at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:631) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626) at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerEnd.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerEnd.java:35) at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56) at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:631) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626) at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49) at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:631) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:450) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:428) at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:140) at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:66) at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.leave(FlowNodeActivityBehavior.java:44) at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.execute(FlowNodeActivityBehavior.java:36) at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:60) at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:631) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626) at org.activiti.engine.impl.pvm.runtime.AtomicOperationProcessStartInitial.eventNotificationsCompleted(AtomicOperationProcessStartInitial.java:45) at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56) at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:631) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626) at org.activiti.engine.impl.pvm.runtime.AtomicOperationProcessStart.eventNotificationsCompleted(AtomicOperationProcessStart.java:62) at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56) at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:631) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.start(ExecutionEntity.java:378) at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:111) at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:37) at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24) at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57) at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45) at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31) at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40) at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35) at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceById(RuntimeServiceImpl.java:101) at org.activiti.explorer.ui.process.listener.StartProcessInstanceClickListener.buttonClick(StartProcessInstanceClickListener.java:71) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510) … 34 moreCaused by: javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "XMLHttpRequest" is not defined. (<Unknown source>#1) in <Unknown source> at line number 1 at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:224) at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:240) at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233) at org.activiti.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:87) … 108 moreCaused by: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "XMLHttpRequest" is not defined. (<Unknown source>#1) at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(ScriptRuntime.java:3770) at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(ScriptRuntime.java:3748) at sun.org.mozilla.javascript.internal.ScriptRuntime.notFoundError(ScriptRuntime.java:3833) at sun.org.mozilla.javascript.internal.ScriptRuntime.name(ScriptRuntime.java:1760) at sun.org.mozilla.javascript.internal.Interpreter.interpretLoop(Interpreter.java:1785) at sun.org.mozilla.javascript.internal.Interpreter.interpret(Interpreter.java:849) at sun.org.mozilla.javascript.internal.InterpretedFunction.call(InterpretedFunction.java:162) at sun.org.mozilla.javascript.internal.ContextFactory.doTopCall(ContextFactory.java:430) at com.sun.script.javascript.RhinoScriptEngine$1.superDoTopCall(RhinoScriptEngine.java:116) at com.sun.script.javascript.RhinoScriptEngine$1.doTopCall(RhinoScriptEngine.java:109) at sun.org.mozilla.javascript.internal.ScriptRuntime.doTopCall(ScriptRuntime.java:3160) at sun.org.mozilla.javascript.internal.InterpretedFunction.exec(InterpretedFunction.java:173) at sun.org.mozilla.javascript.internal.Context.evaluateReader(Context.java:1169) at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:214) … 111 more