LinkedIn
Copied!

Table of Contents

Creating a request for POST, PUT, and PATCH methods by using an automation implementation

Version:

Only available versions of this content are shown in the dropdown

Create a request for your service so that you can define an external API over REST that customers can call for their application. To create the request, select an automation, and map the request headers, resource path parameters, and query string parameters, and request message data to the inputs of the automation.

Create a Service REST rule and configure the resource and processing details. For more information, see Creating a Service REST rule and Defining resource and processing details for a Service REST rule.

The ability to create automations is restricted in Pega Platform 8.4. You can take advantage of this capability in an upcoming Pega Platform release.

  1. In your Service REST rule, click the Methods tab, and then click the method for which you want to create the request body.

  2. In the Implementation section, select Automation.

    If you map to an automation input on the Service tab of your Service REST rule, you must choose Automation as your implementation.
  3. In the Automation field, press the Down arrow key and select an automation from the list.

    The inputs, outputs, and errors associated with the automation are displayed.
  4. In the Inputs section, in the Value fields, enter or select a constant value for the corresponding inputs.

    If you map the input to a piece of the request, the Value fields no longer appear. You can provide a constant value or map the input to a piece of the request. Additionally, for required inputs, you must specify a constant value or map the input to a piece of the request in order to save the rule.
  5. If you selected Enable service SLA with fallback activity on the Service tab of your Service REST rule, in the Fallback activity name field, select or enter a fallback activity to call during a time-out.

    For more information, see Defining resource and processing details for a Service REST rule.

  6. If the activity you selected in step 5 has parameters, in the Parameters section, enter values for the parameters for the fallback activity.

  7. On the Request tab, in the Headers section, configure the header information:

    1. In the Name field, enter the external name of the header field.

    2. In the Description field, describe the purpose of the header.

    3. In the Map to field, specify the destination or the type of destination for the value in Pega Platform:

      • Automation input – Map to an available input specified by the Map to key field.
        If you select a page type input, you must select a scalar property within that page by using the Field within page input option in step 7.e. You cannot map a header to a page or page list directly. Additionally, if you map to a date field or input, the expected format for the date value is Pega API format.
      • Clipboard – Map to the page name or property on the clipboard specified by the Map to key field, or map to a parameter by specifying param.<some param name>.
      • MapTo functions – If additional choices appear, they identify a custom function rule (the Rule-Utility-Function rule type) in a MapTo library. Review the function rule to determine what it does.
    4. In the Map to key field, specify the key to locating the property or the rule in the destination specified in the Map to field:

      • If the Map to value is Clipboard, enter the property name to which to map the data at run time. You can also map to a parameter by specifying param.<some param name>.
      • If the Map to value is a Rule-Utility-Function from a MapTo library, either select a property to hold the results of the function, or leave this field blank, as appropriate for the function.
      • If the Map to value is Automation input, select an input from the list of available inputs.
    5. If you specified a page type input in step 7.d, in the Field within page input field, select a scalar property to use within that page.

  8. If you mapped to an automation input on the Service tab of your REST service, in the Resource path parameters section, in the Map to key field, press the Down arrow key to select an input.

    1. If you specified a page type input, in the Field within page input field, select a scalar property to use within that page.

    If you map to the clipboard on the Service tab of your REST service, the Resource path parameters section is read-only. All methods share the resource path parameters that you configure on the Service tab of your REST service. Resource path parameters are part of the request process of every method. For more information, see Defining resource and processing details for a Service REST rule.
  9. In the Query string section, enter the query string parameters:

    1. In the Name field, enter the name of the input query string.

    2. In the Description field, describe the purpose of the query string.

    3. In the Map to field, specify the destination or the type of destination for the value in Pega Platform:

      • Automation input – Map to an available input specified by the Map to key field.
      • Clipboard – Map to the page name or property on the clipboard specified by the Map to key field. You can also map to a parameter by specifying param.<some param name>.
    4. In the Map to key field, specify the key to locating the property or the rule in the destination specified in the Map to field:

      • If the Map to value is Clipboard, enter the property name to which the data be mapped at run time. You can also map to a parameter by specifying param.<some param name>.
      • If the Map to value is Automation input, select an input from the list of available inputs.
      • If the Map to value is a Rule-Utility-Function from a MapTo library, either select a property to hold the results of the function or leave this field blank, as appropriate for the function.
    5. If you specified a page type input in step 9.d, in the Field within page input field, select a scalar property to use within that page.

  10. In the Message data section, in the How request body maps to inputs field, specify whether the request builds from one input or multiple inputs.

    • If you build a request from one input, go to step 10.a.
    • If you build a request from multiple inputs, go to step 11.
    1. In the Description field, enter a short description for the incoming string.

    2. In the Map to field, specify the destination or the type of destination for the value in Pega Platform:

      • Automation input – The source is an automation. If you select this option, review the following details:
        • If you specify a page type input, you can provide a JSON data transform to define how to turn the provided JSON into the page.
        • If you map to a page type input and do not provide a JSON data transform, the system uses a default JSON data transform. The JSON data transform is set to auto-map all and uses Pega API format as the date formatting option.
        • If you map to a page list type input, the system uses automapping logic to convert the JSON array into the page list. Pega API format is the date formatting option.
        • If you map to a scalar input, valid JSON of the same type is expected, for example, strings within quotations or Boolean. Dates are expected to be in Pega API format.
      • Clipboard – The source is a property or a page on the clipboard.
      • JSON – The source is a stream of JSON data formatted by a Page or Page List property.
      • XML parse rule – The source is a rule that maps data from an XML text message into clipboard property values.
      • Delimited parse rule – The source is a rule that uploads data into the system from an external file.
      • Structured parse rule – The source is a rule that imports structured data to the clipboard.
      • HTML postdata – The source indicates that the incoming data value is a stream of data posted from an HTML form that contains property key/value pairs in POST format.
      • MapTo functions – If additional choices appear, they identify a custom function rule (Rule-Utility-Function rule type) in a MapTo library. Review the function rule to determine what it does.
    3. Optional:

      If you select JSON in step 10.b, you can select the Use fast processing check box to improve processing speed.

    4. In the Map to key field, specify the key to locating the property or the rule in the destination specified in the Map to field.

    5. If you specified a page type input in step 10.d, in the JSON data transform field, select the JSON data transform that you want to use to turn the provided JSON into a page.

  11. To build a request from multiple inputs, complete the following steps:

    If you build from multiple inputs, the request must be a JSON object.
    1. In the Name field, enter the name of the input to map to the request body.

      The values that you enter in the Name field for each output become the fields of the root JSON object.

    2. In the Description field, enter a short description for the incoming string.

    3. In the Map to field, select Automation input.

    4. In the Map to key field, select the key to locating the property or the rule in the destination specified in the Map to field.

      The Map to and Map to key fields are used to specify what to do with the value in those root fields.

    5. If you specified a page type input in step 11.d, in the JSON data transform field, select the JSON data transform that you want to use to turn the provided JSON into a page.

  12. Click Save.

Have a question? Get answers now.

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