bpmncamundacamunda-modeler

Add Date-Variable to Camunda-BPMN via Rest


I have a camunda bpmn workflow where the start-events required some variables. One of the needed variable is of type 'date':

enter image description here

{
  "variables": {
    "stichtagFrist": {
      "value": "2021-09-08T00:00:00",
      "type": "date"
    }
  }
}

now trying to add a new Instance having the above mentioned json, I get the following exception:

Cannot instantiate process definition d1f43d8e-211f-11ec-8fdf-0242ac110002: Cannot convert value '2021-09-08T00:00:00' of type 'date' to java type java.util.Date"

How do I need to POST the json that Camunda can interpret it as "date" so that I can use this variable e.g. in timer-events etc.?

Are there any rules for booleans too?


Solution

  • https://github.com/camunda/camunda-bpm-platform/blob/7c5bf37307d3eeac3aee5724b6e4669a9992eaba/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/VariableValueDto.java#L109

    Uses a Jackson ObjectMapper to parse the value. It requires this format:

    {
      "variables": {
        "stichtagFrist": {
          "value": "2021-09-08T00:00:00.0+0000",
          "type": "date"
        }
      }
    }