I have an activity calling a Connector whose HTTP Method is GET via the activity method 'Connect-REST'.
It might happen that the service returns an HTTP Sttaus of 500/503.
In this case, before the end of the method 'Connect-REST', an exception gets thrown in the predefined activity pyInvokeRESTConnector CL: Rule-Connect-REST RS:Pega-IntegrationEngine:07-10-23 with the following exception trace:
com.pega.pegarules.pub.services.InboundMappingException: Error mapping incoming response to .Response.response_GET: org.codehaus.jackson.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [Source: java.io.StringReader@4f0f4729; line: 1, column: 2]
and the processing of the rest of the activity stops.
Any ideas on how to handle a return the exception thrown by the activity pyInvokeRESTConnector ?
***Updated by Moderator: Marissa: Moved from Pega Academy to Product Support Community, updated categories***
I am not very sure about exception handling in CONNECT-REST but I also faced similer exception.
In my case it was due to different type of response format. Expected format was JSON but received response was of XML format.
This error could be due to xml response and your connect-rest response mapping configured for JSON. Try to get JSON output from source or else change the response mapping to accept xml output(by using parse xml rule).
I have implemented as per your suggestion but I still get the same issue.
Below is a screenshot of my Error Handling:
The workaround I came up with i shaving one Connect REST that has no Response mapping so it only returns the HTTP Status. Then if the HTTP Status is as expected (200) then I call another Connect REST (similiar to th eprevious one) but that has a JSON response mapping (so I can retrieve the data I need).
Do you believe there is a better way to handle unexpected html response (when the correct response that needs to be mapped is in JSON format) ?