Question

How to avoid pxobjclass filed from REST API service response in Pega 7.1.7

while building Rest API service, when converting a pagelist/page to JSON response, it is taking pxobjclass also as a field. We need to drop the pxobjclass from the JSON response. Appreciate any insights on this.

Platform - 7.1.7

Comments

Keep up to date on this post and subscribe to comments

May 31, 2019 - 4:48pm

Hi Sridhar,

Below discussion might help you to achieve your requirement,

https://community1.pega.com/community/pega-support/question/pega-719-how-remove-pxobjclass-json-response

Regards,

Mahesh M

Pega
June 1, 2019 - 2:43am

Hi Sridhar,

Set Map from JSON directly (Enter the reference to a Page or Page List property) in response tab which just generate response in json without having pxobjclass in it.

Thanks,
Abhinav

Pega
October 18, 2019 - 1:32am

You can convert your Page into a string using function @(Pega-RULES:Page).pxConvertStringToPage(tools, myStepPage, Param.Request, "json"), by giving the response page as the step page.

Once the page is converted into a string, you can remove the pxObjClass from the string using REGEX.

Param.JSONResponse = @(Pega-RULES:Page).pxConvertStringToPage(tools, myStepPage, Param.Request, "json")

Param.JSONResponse = @pxReplaceAllViaRegex(Param.JSONResponse,",.*?\"pxObjClass\":\"\"","")

Param.JSONResponse = @pxReplaceAllViaRegex(Param.JSONResponse,"\"pxObjClass.*?\n,","")

Param.JSONResponse = @pxReplaceAllViaRegex(Param.JSONResponse,",.*?\"pxObjClass.*?\n","")

 

Param.JSONResponse = @pxReplaceAllViaRegex(Param.JSONResponse,"\"pxObjClass.*?\n","")

These regex are used to remove the pxObjClass of step page and also the pxObjClass in any of the embedded pages / pagelist structure inside the StepPage/

October 18, 2019 - 2:15pm
Response to vsm02

This function was introduced only in 7.1.8. The reporter of this question mentioned he is running on 7.1.7.