Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

Map base64 encoded response returned by Connect-REST call

SA-90518

Summary



A Connect-REST call is made to a Web service that returns an XML response that is in base64 encoded format. The requirement is to map the base64 encoded response to the required response data model on the Pega application.


Error Messages



Not Applicable


Steps to Reproduce



Not Applicable


Root Cause



An issue in the custom application code or rules.


Resolution



Follow the below example to map an XML response encoded in base64 format that is returned by a REST Web Service:
1. Create a Connect-REST Integration for GET Request using below Sample Response XML:

<?xml version="1.0" encoding="UTF-8"?>
<animals>
   <animal type="birdType">
      <name>lion</name>
      <origin>123</origin>
      <color>yellow</color>
   </animal>
   <animal type="fishType">
      <name>tiger</name>
      <origin>1234</origin>
      <size>20</size>
   </animal>
</animals>

The Base64 encoded string for the above Response XML is as below

PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPGFuaW1hbHM+CjxhbmltYWwgdHlwZT0iYmlyZFR5cGUiPjxuYW1lPmxpb248L25hbWU+PG9yaWdpbj4xMjM8L29yaWdpbj48Y29sb3I+eWVsbG93PC9jb2xvcj48L2FuaW1hbD4KPGFuaW1hbCB0eXBlPSJmaXNoVHlwZSI+PG5hbWU+dGlnZXI8L25hbWU+PG9yaWdpbj4xMjM0PC9vcmlnaW4+PHNpemU+MjA8L3NpemU+PC9hbmltYWw+CjwvYW5pbWFscz4=

2. Open the Connect-REST rule when the Connect-REST Integration wizard generates all the rules.
 
3. Navigate to the Response tab of the Get Method to map the response as a Clipboard string instead of the XML Parse rule.

4. Map the response to a string property as the endpoint returns the response in a base64 encode string format.


 
5. Create an activity in the Integration Layer to decode the base64 encoded Response message.
6. Use the Apply-Parse-XML method in the same activity to map the converted XML string to the Clipboard properties in the Integration Layer. The Parse-XML rule used in the activity is the same Parse XML rule which the Create-REST Integration wizard generated in Step 2.


​​​
7. Update the Response data transform which the Create-REST Integration wizard generated to invoke the activity created. In the first step of the Response data transform, the activity created in the Integration layer is invoked to decode the response to the XML Response message and map the XML to the Clipboard properties in the Integration Layer.

In the below example, the @pxExecuteAnActivity(DataSource,Animals) function invokes the 'Animals' activity that is created in the Integration Layer in Step 3.







Below is the result for the data page (D_Animals) execution: