Question
BlueRose Technology
DE
Last activity: 29 Nov 2016 17:05 EST
How to log service request in case of inbound data mapping error
I have requirement to log Service request in table.
I have REST service with JSON request and response.
One of the scenario, I am getting invalid JSON in request and I need to log that JSON so that I can check what request I receivied.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
US
You may use the Tracer to trace the Service REST rule. The following is a PDN link - https://community.pega.com/sites/default/files/help_v72/procomhelpmain.htm
BlueRose Technology
DE
It will help me to debug but as permanent solution I am trying log every request which I will be receiving in to a table. I am trying to get correct location to call activity to save incoming request into table. Exception scenarios, We will not get control in service activity to log request.
Pegasystems Inc.
US
Hi Ibrahim,
You can also use Fiddler to capture the JSON request.
Jason Hall: Testing RESTful WEB APIs with Fiddler
Thanks,
Susan
PEG
PL
You can enable debug on the pyInvokeRestConnector activity.
I have not yet checked this activity but definitely we will have a javastep which will form the request. If you dont want to put debug on full activity, then you need to manually add oLog.infoForced("Request", request) <<soemthing like this to log the message>>.
I will check once and will give you the complete step.
BlueRose Technology
DE
Thanks Rajeev. Logging in connector scenario can be done in multiple places but any suggestion to log request in case of Service.
More particular, If REST service is getting bad request then service activity will not get called and how to log this request in to customized table?
Pegasystems Inc.
IN
>>> If REST service is getting bad request then service activity will not get called and how to log this request in to customized table?
- for both positive & negative paths
- we have to capture the request & response in a page list (of class ServiceLog) for our analysis.
- So create a page list of class org-data-ServiceLog holding the request and response values
- this page list creation should be triggered based on DSS true-ness
- we can either have the InteractionLog
- under pyWorkPage or
- can implement the same way how attachments are implements [LinkedTo and LinkedFrom]
- So org-data-ServiceLog will be the table here with all the required properties
- request
- response
- status, status code, desc, message
- service name
- workobject ID
- interaction time
- error code, description, additional notes, comments,
- So org-data-ServiceLog will be the table here with all the required properties
- So create a page list of class org-data-ServiceLog holding the request and response values
- in failure scenario - the assignment is routed to either workbasket or administrator (other operator) using ticket rule.
- we have to capture the request & response in a page list (of class ServiceLog) for our analysis.
BlueRose Technology
DE
Thanks. But my REST service is doing validations on request and then creating cases. I did not get how it will work in failure scenario. can you please elaborate more.
Pegasystems Inc.
IN
- for a generic or unknown error we would print "Interaction failed, please contact administrator" otherwise we will read the response from connector response page to log.
BlueRose Technology
DE
I did not understand how based on DSS we will capture. and will it work in case of failure?
JP Morgan Chase
IN
Hi Ibrahim ,
We had a similar requirement and the approach we followed was to override the pyInvokeRestConnector to capture the raw response in a new parameter .In the 5th step of the activity you can include the below code.Once you do this you will have all the details on the parameter page and you can use an activity to get details from the parameter page and write it into a table.
if (! (ignoreData || responseMap == null))
{
responseBody = responseMap.get("body");
// CUSTOM CODE TO SET THE WEBSERVICE RESPONSE TO A PARAMETER ON PARAMETER PAGE
tools.getParameterPage().putParamValue("MyRestResponse",responseBody.toString());
Thanks
Dinesh
Updated: 11 May 2016 14:00 EDT
Pegasystems Inc.
IN
- we made an internal request to integration team, to provide extension points to capture responses/requests in pyInvokeRestConnector instead of overriding the entire activity though it is py...
- not sure when we will get this extension point...
BlueRose Technology
DE
For REST service rule, pyinvokeeestconnector activity will not get called.
-
Andre Paquibot
BlueRose Technology
DE
I am able to log request in case of success scenario. This issue still persist for Inbound Data Mapping scenario for REST Service.
Pegasystems Inc.
IN
oLog.infoForced("Post Request Received: " + myStepPage.getXML()); be of help?
BlueRose Technology
DE
where should I add this log message
Pegasystems Inc.
IN
>>> where should I add this log message
- in service activity.
- also the logger 'com.pega.pegarules.integration.engine.internal.services.http.HTTPService' will be helpful to log rest service events.
Amazon.com Inc
US
Hi IbrahimS786,
how about mapping the JSON request and response to a string properties and you do the mapping in your service activity using ClipboardPage.adoptJSONObject(strJSON) and ClipboardPage.getJSON() Engine API methods.
so the control will come to your Service activity and you can handle parsing errors.
Optus
AU
Hi Ibrahim,
Enable the logger "Rule_Obj_Activity.pyInvokeRESTConnector.Rule_Connect_REST.Action" to all will resolve the problem.
For more information on all loggers click here.
Cisco
US
Hi Ibrahim, were you able a find a solution for this?