Custom rest task

Hi

I created a custom rest task for modeler as per the samples provided.
Which looks like this:

{
    "name": "Check The Weather",
    "id": "za.co.twoblacksheep.connector.http.get",
    "label": "Check the weather",
    "appliesTo": [
      "bpmn:Task"
    ],
    "properties": [],
    "scopes": {
      "camunda:Connector": {
        "properties": [
          {
            "label": "ConnectorId",
            "type": "Hidden",
            "value": "Check_the_weather",
            "binding": {
              "type": "property",
              "name": "connectorId"
            }
          },
          {
            "label": "Method",
            "type": "Hidden",
            "value": "GET",
            "binding": {
              "type": "camunda:inputParameter",
              "name": "method"
            }
          },
          {
            "label": "URL",
            "type": "Hidden",
            "value": "http://localhost:8000/api/check_the_weather/",
            "binding": {
              "type": "camunda:inputParameter",
              "name": "url"
            }
          },
          {
            "label": "Web Service Response",
            "type": "String",
            "value": "wsResponse",
            "binding": {
              "type": "camunda:outputParameter",
              "source": "${S(response)}",
              "scriptFormat": "freemarker"
            }
          }
        ]
      }
    }
  }

The engine doesn’t complain about anything and during execution is passes over the task, it just doesn’t call the service. If I change it to a service task I get the error:
The process could not be started. : No connector found for connector id ‘Check_the_weather’ from the tasklist app.

Any ideas?

Since it’s a rest call so connectorId should be “http-connector”.

https://docs.camunda.org/manual/7.12/reference/connect/http-connector/

Hi Alok0305

So I took your advice and changed the connectorId to http-connector and no change, the task is still passed over. I went further to try pull the value of my variable on my final user task labelled Pack for holiday and I am met with the error:

The process could not be started. : Cannot instantiate process definition invokePHPRestService:107:1a218417-849c-11ea-a8c0-aaedfa88b5a3: Unknown property used in expression: ${wsResponse.toString()}. Cause: Cannot resolve identifier 'wsResponse'

I have updated my BPMN to show a ServiceTask that calls the same web service and then I try call it again from my custom template included below.

{
"name": "Check The Weather",
"id": "za.co.twoblacksheep.connector.http.get.Task",
"label": "Check the weather",
"appliesTo": [
  "bpmn:Task"
],
"properties": [],
"scopes": {
  "camunda:Connector": {
    "properties": [
      {
        "label": "ConnectorId",
        "type": "String",
        "value": "http-connector",
        "binding": {
          "type": "property",
          "name": "connectorId"
        }
      },
      {
        "label": "Method",
        "type": "String",
        "value": "GET",
        "binding": {
          "type": "camunda:inputParameter",
          "name": "method"
        }
      },
      {
        "label": "URL",
        "type": "String",
        "value": "http://localhost:8000/api/check_the_weather/",
        "binding": {
          "type": "camunda:inputParameter",
          "name": "url"
        }
      },
      {
        "label": "Web Service Response",
        "type": "String",
        "value": "wsResponse",
        "binding": {
          "type": "camunda:outputParameter",
          "source": "${JSON(response)}",
          "scriptFormat": "freemarker"
        }
      }
    ]
  }
}

}

This is the simple bpmn flow I am trying to execute.

<?xml version="1.0" encoding="UTF-8"?>

<bpmn2:definitions xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:bpmn2=“http://www.omg.org/spec/BPMN/20100524/MODEL” xmlns:bpmndi=“http://www.omg.org/spec/BPMN/20100524/DI” xmlns:camunda=“http://camunda.org/schema/1.0/bpmn” xmlns:dc=“http://www.omg.org/spec/DD/20100524/DC” xmlns:di=“http://www.omg.org/spec/DD/20100524/DI” id="_B0ppIPFYEeOlke_H2tkzCA" targetNamespace=“http://camunda.org/examples” exporter=“Camunda Modeler” exporterVersion=“1.16.2” xsi:schemaLocation=“http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd”>
<bpmn2:process id=“invokePHPRestService” name=“invoke PHP Rest Service” isExecutable=“true”>
<bpmn2:startEvent id=“StartEvent_1” name=“start”>
bpmn2:outgoingSequenceFlow_0f83o3o</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:serviceTask id=“ServiceTask_1” name=“Check if date is holiday”>
bpmn2:extensionElements
camunda:connector
camunda:inputOutput
<camunda:inputParameter name=“url”>http://localhost:8000/api/isholiday</camunda:inputParameter>
<camunda:inputParameter name=“method”>GET</camunda:inputParameter>
<camunda:inputParameter name=“headers”>
camunda:map
<camunda:entry key=“Accept”>application/json</camunda:entry>
</camunda:map>
</camunda:inputParameter>
<camunda:outputParameter name=“JSONResponse”>${JSON(response)}</camunda:outputParameter>
</camunda:inputOutput>
camunda:connectorIdhttp-connector</camunda:connectorId>
</camunda:connector>
</bpmn2:extensionElements>
bpmn2:incomingSequenceFlow_0f83o3o</bpmn2:incoming>
bpmn2:outgoingSequenceFlow_0adtprc</bpmn2:outgoing>
</bpmn2:serviceTask>
<bpmn2:userTask id=“UserTask_1” name=“Pack for holiday”>
bpmn2:extensionElements
camunda:inputOutput
<camunda:inputParameter name=“route”>users.prepare.forholiday</camunda:inputParameter>
<camunda:inputParameter name=“month”>${JSONResponse.jsonPath("$.data.month").stringValue()}</camunda:inputParameter>
<camunda:inputParameter name=“location”>${JSONResponse.jsonPath("$.data.location").stringValue()}</camunda:inputParameter>
<camunda:inputParameter name=“weather”>${weatherResponse.toString()}</camunda:inputParameter>
<camunda:inputParameter name=“wsResponse”>${wsResponse.toString()}</camunda:inputParameter>
</camunda:inputOutput>
</bpmn2:extensionElements>
bpmn2:incomingSequenceFlow_04kfqba</bpmn2:incoming>
bpmn2:outgoingSequenceFlow_6</bpmn2:outgoing>
</bpmn2:userTask>
<bpmn2:userTask id=“UserTask_2” name=“Pack for work”>
bpmn2:extensionElements
camunda:inputOutput
<camunda:inputParameter name=“route”>users.prepare.forwork</camunda:inputParameter>
</camunda:inputOutput>
</bpmn2:extensionElements>
bpmn2:incomingSequenceFlow_06wqlpg</bpmn2:incoming>
bpmn2:outgoingSequenceFlow_5</bpmn2:outgoing>
</bpmn2:userTask>
<bpmn2:endEvent id=“EndEvent_1”>
bpmn2:incomingSequenceFlow_5</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:sequenceFlow id=“SequenceFlow_5” name="" sourceRef=“UserTask_2” targetRef=“EndEvent_1” />
<bpmn2:endEvent id=“EndEvent_2”>
bpmn2:incomingSequenceFlow_6</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:sequenceFlow id=“SequenceFlow_6” name="" sourceRef=“UserTask_1” targetRef=“EndEvent_2” />
<bpmn2:endEvent id=“Event_0iog456”>
bpmn2:incomingFlow_0znbjnl</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:sequenceFlow id=“Flow_0znbjnl” sourceRef=“Activity_1nwxqux” targetRef=“Event_0iog456” />
<bpmn2:userTask id=“Activity_1nwxqux” name=“Check vars”>
bpmn2:incomingSequenceFlow_1pbftoq</bpmn2:incoming>
bpmn2:outgoingFlow_0znbjnl</bpmn2:outgoing>
</bpmn2:userTask>
<bpmn2:sequenceFlow id=“SequenceFlow_0f83o3o” sourceRef=“StartEvent_1” targetRef=“ServiceTask_1” />
<bpmn2:exclusiveGateway id=“ExclusiveGateway_1f007dk” name=“isHoliday?” default=“SequenceFlow_1pbftoq”>
bpmn2:incomingSequenceFlow_0adtprc</bpmn2:incoming>
bpmn2:outgoingSequenceFlow_06wqlpg</bpmn2:outgoing>
bpmn2:outgoingSequenceFlow_1ozvbwh</bpmn2:outgoing>
bpmn2:outgoingSequenceFlow_1pbftoq</bpmn2:outgoing>
</bpmn2:exclusiveGateway>
<bpmn2:sequenceFlow id=“SequenceFlow_0adtprc” sourceRef=“ServiceTask_1” targetRef=“ExclusiveGateway_1f007dk” />
<bpmn2:sequenceFlow id=“SequenceFlow_06wqlpg” sourceRef=“ExclusiveGateway_1f007dk” targetRef=“UserTask_2”>
<bpmn2:conditionExpression xsi:type=“bpmn2:tFormalExpression”>${not JSONResponse.jsonPath("$.data.isHoliday").boolValue()}</bpmn2:conditionExpression>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id=“SequenceFlow_1ozvbwh” sourceRef=“ExclusiveGateway_1f007dk” targetRef=“Task_0r3zk0a”>
<bpmn2:conditionExpression xsi:type=“bpmn2:tFormalExpression”>${JSONResponse.jsonPath("$.data.isHoliday").boolValue()}</bpmn2:conditionExpression>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id=“SequenceFlow_1pbftoq” sourceRef=“ExclusiveGateway_1f007dk” targetRef=“Activity_1nwxqux” />
<bpmn2:sequenceFlow id=“SequenceFlow_10qz66b” sourceRef=“Task_0r3zk0a” targetRef=“Task_1fepxbw” />
<bpmn2:serviceTask id=“Task_0r3zk0a” name=“Check the weather”>
bpmn2:extensionElements
camunda:connector
camunda:inputOutput
<camunda:inputParameter name=“url”>http://localhost:8000/api/check_the_weather</camunda:inputParameter>
<camunda:inputParameter name=“method”>GET</camunda:inputParameter>
<camunda:inputParameter name=“headers”>
camunda:map
<camunda:entry key=“Accept”>application/json</camunda:entry>
</camunda:map>
</camunda:inputParameter>
<camunda:outputParameter name=“weatherResponse”>${JSON(response)}</camunda:outputParameter>
</camunda:inputOutput>
camunda:connectorIdhttp-connector</camunda:connectorId>
</camunda:connector>
</bpmn2:extensionElements>
bpmn2:incomingSequenceFlow_1ozvbwh</bpmn2:incoming>
bpmn2:outgoingSequenceFlow_10qz66b</bpmn2:outgoing>
</bpmn2:serviceTask>
<bpmn2:task id=“Task_1fepxbw” name=“Check the weather again” camunda:modelerTemplate=“za.co.twoblacksheep.connector.http.get.Task”>
bpmn2:extensionElements
<camunda:connector inout="">
camunda:inputOutput
<camunda:inputParameter name=“method”>GET</camunda:inputParameter>
<camunda:inputParameter name=“url”>http://localhost:8000/api/check_the_weather/</camunda:inputParameter>
<camunda:outputParameter name=“wsResponse”>
<camunda:script scriptFormat=“freemarker”>${S(response)}</camunda:script>
</camunda:outputParameter>
</camunda:inputOutput>
camunda:connectorIdhttp-connector</camunda:connectorId>
</camunda:connector>
</bpmn2:extensionElements>
bpmn2:incomingSequenceFlow_10qz66b</bpmn2:incoming>
bpmn2:outgoingSequenceFlow_04kfqba</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:sequenceFlow id=“SequenceFlow_04kfqba” sourceRef=“Task_1fepxbw” targetRef=“UserTask_1” />
</bpmn2:process>
<bpmndi:BPMNDiagram id=“BPMNDiagram_1”>
<bpmndi:BPMNPlane id=“BPMNPlane_1” bpmnElement=“invokePHPRestService”>
<bpmndi:BPMNEdge id=“BPMNEdge_SequenceFlow_6” bpmnElement=“SequenceFlow_6” sourceElement="_BPMNShape_UserTask_6" targetElement="_BPMNShape_EndEvent_5">
<di:waypoint x=“1218” y=“122” />
<di:waypoint x=“1268” y=“122” />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id=“BPMNEdge_SequenceFlow_5” bpmnElement=“SequenceFlow_5” sourceElement="_BPMNShape_UserTask_7" targetElement="_BPMNShape_EndEvent_4">
<di:waypoint x=“790” y=“326” />
<di:waypoint x=“840” y=“326” />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id=“Flow_0znbjnl_di” bpmnElement=“Flow_0znbjnl”>
<di:waypoint x=“790” y=“221” />
<di:waypoint x=“840” y=“221” />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_4" bpmnElement=“StartEvent_1”>
<dc:Bounds x=“170” y=“203” width=“36” height=“36” />
bpmndi:BPMNLabel
<dc:Bounds x=“178” y=“244” width=“22” height=“14” />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_ServiceTask_17" bpmnElement=“ServiceTask_1”>
<dc:Bounds x=“255” y=“181” width=“100” height=“80” />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_UserTask_6" bpmnElement=“UserTask_1”>
<dc:Bounds x=“1118” y=“82” width=“100” height=“80” />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_UserTask_7" bpmnElement=“UserTask_2”>
<dc:Bounds x=“690” y=“286” width=“100” height=“80” />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_4" bpmnElement=“EndEvent_1”>
<dc:Bounds x=“840” y=“308” width=“36” height=“36” />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_5" bpmnElement=“EndEvent_2”>
<dc:Bounds x=“1268” y=“104” width=“36” height=“36” />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id=“Activity_18w2b5w_di” bpmnElement=“Activity_1nwxqux”>
<dc:Bounds x=“690” y=“181” width=“100” height=“80” />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id=“Event_0iog456_di” bpmnElement=“Event_0iog456”>
<dc:Bounds x=“840” y=“203” width=“36” height=“36” />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id=“SequenceFlow_0f83o3o_di” bpmnElement=“SequenceFlow_0f83o3o”>
<di:waypoint x=“206” y=“221” />
<di:waypoint x=“255” y=“221” />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id=“ExclusiveGateway_1f007dk_di” bpmnElement=“ExclusiveGateway_1f007dk” isMarkerVisible=“true”>
<dc:Bounds x=“404” y=“196” width=“50” height=“50” />
bpmndi:BPMNLabel
<dc:Bounds x=“446” y=“193” width=“51” height=“14” />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id=“SequenceFlow_0adtprc_di” bpmnElement=“SequenceFlow_0adtprc”>
<di:waypoint x=“355” y=“221” />
<di:waypoint x=“404” y=“221” />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id=“SequenceFlow_06wqlpg_di” bpmnElement=“SequenceFlow_06wqlpg”>
<di:waypoint x=“429” y=“246” />
<di:waypoint x=“429” y=“326” />
<di:waypoint x=“690” y=“326” />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id=“SequenceFlow_1ozvbwh_di” bpmnElement=“SequenceFlow_1ozvbwh”>
<di:waypoint x=“429” y=“196” />
<di:waypoint x=“429” y=“122” />
<di:waypoint x=“566” y=“122” />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id=“SequenceFlow_1pbftoq_di” bpmnElement=“SequenceFlow_1pbftoq”>
<di:waypoint x=“454” y=“221” />
<di:waypoint x=“690” y=“221” />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id=“SequenceFlow_10qz66b_di” bpmnElement=“SequenceFlow_10qz66b”>
<di:waypoint x=“666” y=“122” />
<di:waypoint x=“808” y=“122” />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id=“ServiceTask_1lrxk2w_di” bpmnElement=“Task_0r3zk0a”>
<dc:Bounds x=“566” y=“82” width=“100” height=“80” />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id=“Task_1fepxbw_di” bpmnElement=“Task_1fepxbw”>
<dc:Bounds x=“808” y=“82” width=“100” height=“80” />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id=“SequenceFlow_04kfqba_di” bpmnElement=“SequenceFlow_04kfqba”>
<di:waypoint x=“908” y=“122” />
<di:waypoint x=“1118” y=“122” />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>

I am using the latest modeler and camunda CE

I’m still stuck here, does anyone have anything to try? Any help is greatly appreciated.

Hi @lindsay,

I tried to paste your XML into the modeler, but without luck. Markdown mixed up the quotes in the XML.

Could you please upload the BPMN diagram as a file?

Cheers, Ingo

Hi @Ingo_Richtsmeier,

I have uploaded both the bpmn file and the “check_the_weather.json” template.

At the moment when I execute the flow I get the following output.
[2020-04-27 14:02:43] local.INFO: isHoliday called true
[2020-04-27 14:02:43] local.INFO: Checking the weather built-in-connector

Where I am expecting:
[2020-04-27 14:02:43] local.INFO: isHoliday called true
[2020-04-27 14:02:43] local.INFO: Checking the weather built-in-connector
[2020-04-27 14:02:43] local.INFO: Checking the weather custom-template-param

Files:

I appreciate the help.