Creating a request for POST, PUT, and PATCH methods by using an activity 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 activity, and map the request headers, resource path parameters, query string parameters, and request message data to the parameters or primary page of the activity.
Before you begin: 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.
- 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 Activity.
-
In the Activity field, press the Down arrow key and
select an activity from the list.
Result: The parameters of the activity are displayed in the Parameters section.
- If you provide a value for a parameter in this section and you use Clipboard to map a piece of the request to that same parameter, this value becomes a default. If the request contains a value, then that value is used instead of the parameter that you provided.
- If a request contains a query string parameter that is not mapped to an input in the section for that method, the activity receives that value as a parameter with the same name.
-
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 4 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:
- 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.
Note: 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. -
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:
- 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>.
- 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.
-
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 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.
-
In the Message data section, complete the following
steps:
- 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:
- 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.
- Optional: If you selected JSON, 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.
- Click Save.