Unable to evaluate script - Expected ; but found eof

Gentlemen,

I’m having an issue today and would like to request a 2nd pair of eyes on my test.

I’m getting an “Expected ; but found eof” which makes me believe there is a missing a “;” (Semi-Colon) but I don’t believe it is required for the URL input variable and the payload.

I’ve attached my simplified testing BPMN file.

Below that I’ve posted the Error Stack.

Thanks in advance,

Ash

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0igvrl9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.8.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
  <bpmn:process id="Testing" name="Testing" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>Flow_1g98ytz</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:serviceTask id="Activity_1qlu6ce" name="HTTP Connector Test" camunda:asyncBefore="true">
      <bpmn:extensionElements>
        <camunda:connector>
          <camunda:inputOutput>
            <camunda:inputParameter name="url">
              <camunda:script scriptFormat="javascript">https://domain.com/rest-api.json?authorization=11111111</camunda:script>
            </camunda:inputParameter>
            <camunda:inputParameter name="method">POST</camunda:inputParameter>
            <camunda:inputParameter name="headers">
              <camunda:map>
                <camunda:entry key="content-type">application/json</camunda:entry>
              </camunda:map>
            </camunda:inputParameter>
            <camunda:inputParameter name="payload">{
  "object": {
    "data1": 1,
    "data2": "Test",
    "data3": 1,
    "fields":
      [
        {"value":"TestData","id":10},
        {"value":"11111111111111111111111111111111","id":12},
        {"value":"1","id":14}
      ]

   }
}</camunda:inputParameter>
          </camunda:inputOutput>
          <camunda:connectorId>http-connector</camunda:connectorId>
        </camunda:connector>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_1g98ytz</bpmn:incoming>
      <bpmn:outgoing>Flow_0smwph2</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_1g98ytz" sourceRef="StartEvent_1" targetRef="Activity_1qlu6ce" />
    <bpmn:endEvent id="Event_0p66iqh">
      <bpmn:incoming>Flow_0smwph2</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_0smwph2" sourceRef="Activity_1qlu6ce" targetRef="Event_0p66iqh" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Testing">
      <bpmndi:BPMNEdge id="Flow_1g98ytz_di" bpmnElement="Flow_1g98ytz">
        <di:waypoint x="215" y="117" />
        <di:waypoint x="280" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0smwph2_di" bpmnElement="Flow_0smwph2">
        <di:waypoint x="380" y="117" />
        <di:waypoint x="452" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="179" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1qlu6ce_di" bpmnElement="Activity_1qlu6ce" bioc:stroke="rgb(67, 160, 71)" bioc:fill="rgb(200, 230, 201)">
        <dc:Bounds x="280" y="77" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0p66iqh_di" bpmnElement="Event_0p66iqh">
        <dc:Bounds x="452" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Here is the Error Stack;

org.camunda.bpm.engine.ScriptEvaluationException: Unable to evaluate script while executing activity 'Activity_1qlu6ce' in the process definition with id 'f9d509b8-0107-11ec-b6bb-0242ac170002':<eval>:1:87 Expected ; but found eof
https://domain.com/rest-api.json?authorization=111111111
                                                                                       ^ in <eval> at line number 1 at column number 87
	at org.camunda.bpm.engine.impl.scripting.SourceExecutableScript.evaluate(SourceExecutableScript.java:71)
	at org.camunda.bpm.engine.impl.scripting.ExecutableScript.execute(ExecutableScript.java:63)
	at org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment.execute(ScriptingEnvironment.java:101)
	at org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment.execute(ScriptingEnvironment.java:87)
	at org.camunda.bpm.engine.impl.delegate.ScriptInvocation.invoke(ScriptInvocation.java:47)
	at org.camunda.bpm.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:58)
	at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocationInContext(DefaultDelegateInterceptor.java:92)
	at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:63)
	at org.camunda.bpm.engine.impl.scripting.ScriptValueProvider.getValue(ScriptValueProvider.java:46)
	at org.camunda.bpm.engine.impl.core.variable.mapping.InputParameter.execute(InputParameter.java:46)
	at org.camunda.bpm.engine.impl.core.variable.mapping.IoParameter.execute(IoParameter.java:51)
	at org.camunda.bpm.engine.impl.core.variable.mapping.IoMapping.executeInputParameters(IoMapping.java:39)

Solved!!!

I tore it apart and figured it out.

#GirlProgrammersRules

1 Like

Hi @Ashley,

https://docs.camunda.org/manual/7.15/user-guide/process-engine/scripting/#use-scripts-as-inputoutput-parameters

When script is used as input/output parameters then that the last statement of the script is returned

<camunda:inputParameter name="url">
    <camunda:script scriptFormat="javascript">
		var url = "https://domain.com/rest-api.json?authorization=11111111";
		url
	</camunda:script>
</camunda:inputParameter>
1 Like

@hassang Thanks!

I’ve actually shortened it to just the string itself and it works. I’m assuming this is more efficient since it does not use additional memory for the var.

https://domain.com/rest-api.json?authorization=11111111

Hi @Ashley,

Exactly, since it is a straightforward text assignment then no need to use script

1 Like