DMN Map input "Object is not deserialized" exception

Just checked DMN cloud. Well done.

Need some help with Map input via REST api to evaluate DMN, hope you can help.

I have a DMN which uses a JUEL expression in the output “params.score+input1+input2”, where params.score is fed by the service task out param in the process and input1 & input2 are user inputs.
I could construct a quick unit test ( Ref: https://bitbucket.org/bkumar/dmn-test/raw/b042c59ddc3f55e53981ee5b01267108ebbe53e5/src/test/java/org/camunda/bpm/JobFlowUnitTest.java ) which works fine.

However when a REST request is fired it throws “Object is not deserialized” exception. Not quite sure if I am passing the map string correctly, tried various flavours but no luck. Hope you can thrown me a hint here.

Command:
curl -H “Content-Type: application/json” -X POST -d ‘{
“variables” : {
“params”: {
“type”: “Object”,
“value”: “{"score" : { "value" : 1000, "type" : "integer" }}”,
“valueInfo”: {
“objectTypeName”: “java.util.HashMap”,
“serializationDataFormat”: “application/json”
}
},
“input1” : { “value” : -50, “type” : “integer” },
“input2” : { “value” : -25, “type” : “integer” }
}
}’ http://localhost:9090/rest/engine/default/decision-definition/key/job-score/evaluate

Full source @ Bitbucket

Process definition image @ Cawemo | Welcome

Thanks for your valuable time.

Hi Bharat,

currently, it is not possible to pass a serialized value into a decision. Note that this is different from Java API since you pass the map as a java object and not as serialized value. If you use a serialized value in your test case (e.g. Variables.serializedObjectValue( … )) then the same exception occurs.

I see two workarounds

  • unpack the map and pass the variables one by one
  • use a JSON object in combination with Camunda Spin

Change your request body to

{
"variables" : {  
  "params": {
    "value": "{\"score\": 1000}",
    "type":"json"
    },  
  "input1" : { "value" : -50, "type" : "integer" },
  "input2" : { "value" : -25, "type" : "integer" }
  }
}

And use Spin in your expression to access the JSON variable.

S(params).prop("score").value() + input1 + input2

Does this help you?

Feel free to create a feature request or provide a pull request.

Greetings,
Philipp

Thanks Philipp.

Created a feature request @ https://app.camunda.com/jira/browse/CAM-5678