I'm calling a REST service using GET method which returns a single value, say : 99.
As this is not a valid json object I use the bodyAsString property but I get an exception :
org.bonitasoft.engine.connector.ConnectorException: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `java.util.HashMap` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('99')
I don't understand why Bonita is trying to deserialize it into a HashMap when I request a String ?
Did you check if the request response doesn't have a Json content-type ? If it has a content-type header with application/json then the connector will try to interpret the response as a json object and failed if the response body is not json.
You're right, the web service is returning a json content-type header despite returned value is not valid json.
Thank you for the hint !
Still, I think there is a bug in the connector :
- Response body "abc" for instance is a valid json value and should be interpreted as a String (same for dates, numbers, boolean values...).
- Even in case of a malformed json expression, when using bodyAsString as a workaround the connector should not try to interpret the response as a json object even if the response has a json content-type.
It is possible to be more permissive and have a fallback behavior, feel free to contribute a pull request here