I have the following parameters in a POST:
{“variables”:
{
“acct_safekeep”:{“value”:“STT”, “type”:“String”},
“share_price”:{“value”:65.0, “type”:“Double”},
“trade_date”:{“value”:“2019/01/31”, “type”:“Date”}
}
}
However, I get an error when I send it:
{
“type”: “InvalidRequestException”,
“message”: “Cannot convert value ‘2019/01/31’ of type ‘Date’ to java type java.util.Date”
}
Sasha thanks for getting back quickly.
I don’t see where I would do the conversion. from string -> Date.
Does the conversion take place in the rule? Where would this code be placed?
String string = "2019/01/31";
DateFormat format = new SimpleDateFormat("yyyy/mm/dd", Locale.ENGLISH);
Date date = format.parse(string);
Based on the exception you get, I assume your server uses Java and expects “java.util.Date” whereas in the decision table the typeRef declares “date”. This is most likely the reason the value of “2019/01/31” can not be properly resolved.
My suggestion would be to change the typeRef to use a string and then let the server expect a string. This allows you to receive your POST request and then change the string to Java’s date format.
Btw, do you have access to the server (where the call will be resolved)?
Does the conversion take place in the rule? Where would this code be placed?
The DMN engine supports a date type which is a combination of date and time. By default, the data type transformer accept objects of the type java.util.Date and Strings having the format yyyy-MM-dd'T'HH:mm:ss .
If you prefer another format or different representation of a date, implement a custom type and replace the default transformer.
In that case you have to change the value of your date to conform to the expected format, as described above.
As far as I know (not really sure here), Java uses the ISO 8601 standard for dates. That means you have to pass your date to the DMN in accordance to those formats
Thanks, that got me through the original issue. I am now getting a { "type": "RestException", "message": "Cannot evaluate decision ae914c03-2890-11e9-9283-0242ac110002: Exception while evaluating decision with key 'null'" }
what is the best way to debug this? logs? debug output? How do I know which key is null?
so I looked at the logs in the container, and I see this cryptic message:
Caused by: org.camunda.bpm.dmn.feel.impl.juel.FeelMissingVariableException: FEEL-01009 Unable to resolve variable ‘STT’ in expression ‘STT’
STT should be the value of the field “account”, why does it think it is a variable? Caused by: org.camunda.bpm.dmn.feel.impl.juel.FeelMissingVariableException: FEEL-01009 Unable to resolve variable 'STT' in expression 'STT'
I re-deployed your version and send a postman “POST” with the following:
{“variables”:
{
“acct_safekeep”:{“value”:“STT”, “type”:“String”},
“share_price”:{“value”:“65.0”, “type”:“Double”},
“trade_date”:{“value”:“2019-01-31T10:11:00.000+0100”, “type”:“Date”}
}
}
I got the same error.
I am calling it with: http://localhost:8080/engine-rest/decision-definition/cd9eb237-2951-11e9-9283-0242ac110002/evaluate