<bpmn:startEvent id="StartEvent_1t6nxib" camunda:formKey="embedded:deployment:input-terms.html">
<bpmn:extensionElements>
<camunda:executionListener event="start">
- <camunda:script scriptFormat="javascript">var results = S('{}');
-execution.setVariable("results", results)</camunda:script>
+ <camunda:script scriptFormat="javascript">// make variable global
+execution.setVariable("results", S('[]'))</camunda:script>
</camunda:executionListener>
</bpmn:extensionElements>
<bpmn:outgoing>SequenceFlow_15dip2q</bpmn:outgoing>
var term = execution.getVariable("term");
var analysis = execution.getVariable("analysis");
var termStr = term.prop('term').value();
-//print (termStr)
-results.prop(termStr, analysis);
-//print (analysis)
-//print (results)
+
+// this is for dictionary
+//results.prop(termStr, analysis);
+// this is for list
+var item = {};
+item[termStr] = analysis;
+results.append(item)
+
execution.setVariable("results", S(results))</camunda:script>
</camunda:executionListener>
</bpmn:extensionElements>
<camunda:connector>
<camunda:inputOutput>
<camunda:inputParameter name="url">http://reporting:80/generatePDF/</camunda:inputParameter>
- <camunda:inputParameter name="method">GET</camunda:inputParameter>
+ <camunda:inputParameter name="method">POST</camunda:inputParameter>
<camunda:inputParameter name="headers">
<camunda:map>
<camunda:entry key="Accept">application/pdf</camunda:entry>
+ <camunda:entry key="Content-Type">application/json</camunda:entry>
</camunda:map>
</camunda:inputParameter>
<camunda:inputParameter name="payload">${results.toString()}</camunda:inputParameter>
<camunda:outputParameter name="reportPDF">
<camunda:script scriptFormat="javascript">var response = connector.getVariable("response");
-response</camunda:script>
+print ("response: ")
+print (response)
+var file = Java.type('org.camunda.bpm.engine.variable.Variables').fileValue("pdfTest").file(response.getBytes("utf-8")).mimeType('application/pdf').create()
+//response.getBytes("utf-8")
+file</camunda:script>
</camunda:outputParameter>
</camunda:inputOutput>
<camunda:connectorId>http-connector</camunda:connectorId>