Support Article
Error while parsing JSON response in Connect-REST
Summary
When trying to parse an incoming JSON response to a Connect-REST rule, it fails with the following error.
Error Messages
** Error mapping incoming response to .response_POST: com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [map type; class java.util.LinkedHashMap, [simple type, class java.lang.Object] -> [simple type, class java.lang.Object]] from String value ('["Username: username is already being used."]'); no single-String constructor/factory method
at [Source: "[\"Username: username is already being used.\"]"; line: 1, column: 1]
Steps to Reproduce
1. Create Connect-REST using POST method.
2. Configure Connect-REST request and response tab with JSON mapping.
3. Map the request to clipboard.
4. Run the Connect-REST.
Root Cause
A third-party product issue. Users external REST Service is sending a non RFC 4627 compliant JSON String.
Resolution
Here’s the explanation for the reported behavior:
Pega uses third-party (fasterxml) JSON Data binding java API (jackson-databind.jar) to map JSON formatted strings to / from Clipboard.
The version of Jackson Databind API bundled with Pega 7.2.2 is 2.7.4. The JSON types implemented by version Jackson-databind-2.7.4.jar is RFC 4627.
To resolve this issue, one must capture the raw response string into a “Text” property mapped to the Clipboard.
Then use parsing logic to extract the required text into corresponding / appropriate Clipboard property(ies).
Published August 16, 2017 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.