Posted: 30 Oct 2020 0:44 EDT Last activity: 30 Oct 2020 8:07 EDT
Issue while using pxConvertStringToPage to handle REST exception
We were getting 'exception occurred while mapping incoming response to .response_get' while calling a REST service(REST service was initially consumed using Pega wizard). As suggested in many articles (like this: https://collaborate.pega.com/question/exception-occured-while-mapping-incoming-response-responseget)- we tried using clipboard property for mapping response and later converting response into json page using 'pxConvertStringToPage' function. We were mapping results in the following way-
Now this approach is not working for properties for which PEGA OOTB connector wizard create properties with different identifier.
Normally Pega creates such properties with qualifier 'pzExternalName' equal to the original JSON attribute/tag. For example..JSON structure requires 'NAME' property under a pagelist structure(e.g. Data.LIST()). But name property already exists in inheritance(like @baseclass). So Pega wizard created "NAME2" property with 'NAME' as pzExternalName qualifier value.
Now when we are converting response from clipboard property to response_GET page...the structure is getting created with exact attribute name like in service response (i.e. "ParsedJSON.Data.LIST(1).NAME"). Now when we are mapping the entire top level 'ParsedJSON.Data' to 'response_GET.Data', Pega is expecting 'NAME2' property under 'response_GET.Data.List()' whereas 'ParsedJSON.Data.List()' has 'NAME' property. So the mapping gets skipped.
How to handle this issue?
-Withdrawing property ('NAME') in higher inheritance is not an option since it is used in other services in our application
-Mapping properties individually is not an option as 'ParsedJSON' is class-less and source pagelist(ParsedJSON.Data.List()) cannot be defined- throwing error in service response DT
***Edited by Moderator: Pooja to add platform capability tags***
What is the original exception you are getting due to JSON mapping? Can you share the stack trace. Please remove any sensitive information like user name, ip or system name while posting the stack trace? You can try to map the JSON string to data model using below adoptJSONObject method as well.
We are not getting exception while converting JSON response from string to JSON page using pxConvertStringToPage function. The resultant 'ParsedJSON' page that is getting created follows the exact structure as that of the service JSON response(like ParsedJSON.Data.List(<CURRENT>).NAME).
Now in initial service consumption Pega created properties with varying identifiers(like NAME2). So the data model for the response_GET is created in such a way that it will create structure like this: response_GET.Data.List(<CURRENT>).NAME2 with NAME2 property having qualifier 'pzExternalName' of value 'NAME' in case we used Pega OOTB Connect-Rest configuration. But here we are using clipboard property for receiving service response as explained in original post.
We are trying to simply map values by Property-set in the service response data transform
SET response_GET.Data equal to ParsedJSON.Data
) so that the top level page and it's embedded page gets mapped. But response_GET.Data.List(<CURRENT>).NAME2 is not getting mapped since ParsedJSON .Data.List(<CURRENT>) doesn't have NAME2, only NAME.
Now without changing service structure and new property, can we change anything in Pega so that the response_GET.Data.List(<CURRENT>).NAME2 understands that it has to get mapped with ParsedJSON.Data.List(<CURRENT>).NAME ?