Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

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.

Configuring a JSON data transform as a request data transform in data pages

Updated on May 4, 2020

You can use a JSON data transform as a request data transform in data pages for REST integration to make serialization and deserialization faster and more efficient. The REST Integration wizard creates a REST connector, creates a class, generates the data model, and creates the request and response data transforms that turn the integration layer into the data layer. For JSON data models, the data transforms that the REST Integration wizard creates work, but they are slower and less efficient than JSON data transforms. You can replace the request and response data transforms created by the REST Integration wizard with JSON request and response data transforms.

To use a JSON data transform, create a JSON data transform and configure the response or request data transform created by the REST Integration wizard to use it. For instructions on configuring a response JSON data transform, see the following instructions. For instructions on configuring a JSON request data transform, see Configuring a JSON data transform as a response data transform in data pages.

Configuring JSON request data transforms has the following high-level steps:

  1. Create a REST connector by using the REST Integration wizard
  2. Configure the data page
  3. Create the JSON request data transform
  4. Configure the request data transform

Creating a REST connector by using the REST Integration wizard

Run the REST Integration wizard to create a REST connector by clicking Designer Studio > Integration > Connectors > Create REST Integration. For details about the REST Integration wizard, see Creating REST integration.

Configuring the data page

Requests require a page parameter instead of a list of individual parameters. In addition, caching is not usually required for requests. Configure the page parameter and disable caching by causing the contacted page to reload every time it is contacted. If your POST REST service is idempotent and requires caching, see Enabling caching.

  1. Open the data page created by the REST Integration wizard by clicking the link in the Data Page Created field in the Generation Summary page.
  2. Click the Parameters tab.
  3. In the Name field, enter the name of the data page, for example, pageName.
  4. In the Data type field, click String.

    Data page Parameters tabData page Parameters tab

  5. Click the Load Management tab.
  6. Select Reload once per interaction.
  7. Click Save.

Creating the JSON request data transform

Create the JSON request data transform to use in the request data transform created by the REST Integration wizard. The JSON data transform must be created in the same class as the request data transform. You can determine the class by opening the data page from the Generation Summary page generated by the REST Integration wizard, and clicking the Open icon next to the request data transform.

JSON data transform Definition tab

JSON Request data transform Definition tab

  1. In the Application Explorer, locate the class that the response data transform is in, for example, Code-Pega-List.
  2. Right-click the class, and click Create > Data Model > Data Transform.
  3. In the Label field, enter a short description.
  4. In the Data model format field, click JSON.
  5. In the Add to ruleset field, select the ruleset. It is recommended that you use the same ruleset as the data page.

    JSON data transform

    JSON Data Transform

  6. Click Create and open.
  7. Create the mapping between the clipboard and the JSON data by adding the fields that are in the request data transform to the JSON data transform. The following example shows the fields in the request data transform.
    JSON fields might not match the fields in the response data transform if the JSON fields contained characters that cannot be used in property names. In this case, the REST Integration wizard adjusts the names so that they do not contain unsupported characters. To find the property names for the JSON side of the transform, open the property rule and look at the pzExternalName property qualifier.

    Request data transform Definition tab

    1. In the Clipboard field, enter the first property.
    2. In the JSON field, enter the corresponding JSON property.
    3. Click Add element to repeat these steps for every field that you need to add. The following example shows the JSON data transform with the fields from the request data transform.
  8. Click Save.

Configuring the request data transform

Update the request data transform generated by the REST Integration wizard to use the new JSON request data transform.

  1. Open the request data transform generated by the REST Integration wizard by clicking the Open icon next to the Request Data Transform field on the data page.
  2. Click the Parameters tab.
  3. In the Name field, enter the data page name, for example, pageName.
  4. In the Data type field, click Page Name.
  5. Click the Pages & Classes tab.
  6. In the Page name field, enter the data page name, for example, pageName.
  7. In the Class field, select the same class as the request data transform.
  8. Click the Definition tab.
  9. Delete row 2 by clicking the Trash can icon next to row 2.
  10. Create a new row 2 by clicking the Add a row icon.
  11. In the Action field, click Update Page.
  12. In the Target field, enter the data page name, for example, pageName.
  13. In step 2.1 in the Action field, click Apply Data Transform.
  14. In the Target field, enter the JSON request data transform that you just created.

    Request data transform Definition tab

    Request data transform Definition tab

  15. Click the Gear icon in step 2.1.
  16. Click Pass Current Parameter Page to configure parameters to be passed by reference. The executionMode field becomes blank and the execution mode defaults to serialize. Pages that are passed into the data transform are turned into JSON using the mapping configuration, and the resulting JSON is returned in a parameter. The next steps map the incoming pages to the parameter that will contain the results.
  17. Click Submit.
  18. Map the incoming pages to the parameter that will contain the results.
    1. Add row 3 by clicking Add a row.
    2. In the Action field, click Set.
    3. In the Target field, enter .pyJsonData.
    4. In the Source field, enter Param.jsonData.

      Updated request data transform

      Updated request data transform

  19. Configure the REST connector to use .jsonData.
    1. Open the REST connector by clicking the Open icon next to the Name field on the data page.

      Data page Name field

      Data page

    2. Click the Methods tab.
    3. In the the Message data section for the method that you are configuring, in the Map from field, click Clipboard.
    4. In the Map from key field, enter .pyJsonData

      Message data

      Message data

  20. Click Save.

Enabling caching

If your POST REST service is idempotent (consistently provides the same response), you can enable caching. When caching is enabled, the response from the remote service for the request JSON is cached, ensuring that subsequent calls to the data page with exactly the same request JSON return a cached response instead of making a new call to the remote service.

To enable caching, you pass the JSON data to the data page and call the data transform outside of the data page.

  1. From the Records Explorer, click Data Model > Data Page.
  2. Click the data page used by the request data transform to open it.
  3. Click the Parameters tab.
  4. Delete the pageName parameter by clicking the Trash can icon.
  5. In the Name field, enter jsonData.
  6. In the Data type field, click String.

    Data page configured for caching

    Data page configured for caching

  7. Click the Load Management tab.
  8. Clear Reload once per interaction.
  9. Click Save.
  10. Open the request data transform generated by the REST Integration wizard by clicking the Open icon next to the Request Data Transform field on the data page.
  11. Click the request data transform that is associated with this data page to open the rule form.
  12. Delete step 2 by clicking the Trash can icon.

 

Request data transform configured for caching

Request data transform configured for caching

  1. Click Save.

 

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us