Creating a request for POST, PUT, and PATCH methods by using an automation implementation
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.
- In your Service REST rule, click the Methods tab, and then click the method for which you want to create the request body.
- In the Implementation section, select
Automation.
- In the Automation field, press the Down arrow key and select an automation from the list.
- In the Inputs section, in the Value
fields, enter or select a constant value for the corresponding inputs.
- 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.
- If the activity you selected in step 5 has parameters, in the Parameters section, enter values for the parameters for the fallback activity.
- On the Request tab, in the Headers
section, configure the header information:
- In the Name field, enter the external name of the header field.
- In the Description field, describe the purpose of the header.
- 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, 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.
- 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.
- 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.
- 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.
- If you specified a page type input, in the Field within page input field, select a scalar property to use within that page.
- In the Query string section, enter the query string
parameters:
- In the Name field, enter the name of the input query string.
- In the Description field, describe the purpose of the query string.
- 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>.
- 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.
- 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.
- 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.
- In the Description field, enter a short description for the incoming string.
- 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.
- Automation input – The source is an
automation. If you select this option, review the following
details:
- Optional: If you select JSON in step 10.b, you can select the Use fast processing check box to improve processing speed.
- 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 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.
- To build a request from multiple inputs, complete the following steps:
- 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.
- In the Description field, enter a short description for the incoming string.
- In the Map to field, select Automation input.
- 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.
- 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.
- In the Name field, enter the name of the input
to map to the request body.
- Click Save.
Previous topic Creating a request for POST, PUT, and PATCH methods by using an activity implementation Next topic Creating a response for Service REST methods by using an activity implementation