How to read or capture Connect-REST failure reason behind 404, 500 error codes

Hi Everyone,

When a Connect-REST fails with 404 and 500 errors codes although the error details are in the backend, is there a way to read them back to calling activity or data page?

I see those details in logs when I enable com.pega.pegarules.integration.engine.internal.connect.rest.RESTConnector to Debug / ALL but, I am not able to find them in any local variable or params of invoke / pyInvokeRESTConnector.

After enabling above setting, log says below

<em><strong>------------------HTTP RESPONSE CONTENTS------------------ 
Response Headers: 
Connection: keep-alive 
Content-Type: application/json 
Date: Tue, 30 May 2023 03:45:43 GMT 
RespRuleErrorCode: 0x00000000 
Transfer-Encoding: chunked 
X-Backside-Transport: FAIL FAIL,FAIL FAIL 
X-Global-Transaction-ID: 804c2337647571677e3fac1f 
 
Response Message Data: 554 bytes received 
{"exceptions":[{"type":"E","code":"1002","message":"ERR3031 PMG/IPA PROV CONT NOT FND FOR PRODUCT"}]} 
 
----------------END HTTP RESPONSE CONTENTS---------------- </strong></em>

I need to read the message variable from above line. Any insight is appreciated.

Pega version: 8.8.1

Thank you!

@GOUTHAMKUMAR Please create the exception data model in your int class or use the function to map the response to clipboard

@Nadimuthu T Thank you for your response.The data model exists already however, it is not working all the time. Its working only for 401 code.

@GOUTHAMKUMAR Pls check the json for 401, it’s may be error page structure

@GOUTHAMKUMAR

use property pyHTTPResponseCode to get errors codes
Ex: D_APIPage.pyHTTPResponseCode

@LANH(ラン) , Thank you for your response. I am able to find the response code but I am not able to read the error code and details of the error.

Issue is resolved. This DSS Pega-IntegrationEngine • http/LegacyResponseMapping was set to true. After changing it to false, it followed the exception structure in response XML.

@Nadimuthu T I verified the response structure in postman. 401 and 404 response structure is same. both

401

{

“exceptions”: [

{

“type”: “E”,

“code”: “401”,

“message”: “FailedToResolveAPIKey”,

“detail”: “dcb9dc9a-9b8b-4a8a-b2bf-610f69be17c9 - The API key for this resource is invalid or missing”

}

]

}

404

{

“exceptions”: [

{

“type”: “E”,

“code”: “1002”,

“message”: “ERR3011 IPA ID NOT FOUND ON PROV DB”,

“detail”: “ERR3011 IPA ID NOT FOUND ON PROV DB”

}

]

}