Configuring a REST connector to receive binary attachments
Pega Platform can receive attachments regardless of the content type or response type. Configure a REST connector to receive attachments when your application connects to a service that responds with a binary stream, for example, a PDF file or XLS file.
- Configure your REST connector to map the response to the clipboard.
- On the Methods tab of your REST connector, in the GET section, click the Response tab.
- In the Message data section, in the Map to field, select Clipboard.
- In the Map to key field, enter the map to key property and then click the rule opener.
- Configure the java object property type and the map to key.
- On the Property Record Configuration page, enter a
name for the property, choose a class that you want to associate with
the property, and select a ruleset and a ruleset version in which you
want to store the property.For more information, see Properties.
- Click Create and open.
- On the General tab, in the Property type section, click .
- Click Save.
- Click Save on the Connect REST rule form.
- On the Property Record Configuration page, enter a
name for the property, choose a class that you want to associate with
the property, and select a ruleset and a ruleset version in which you
want to store the property.
- In the activity, define the page on which the response is mapped.
- On the Steps tab of the activity, in the
Method field, press the Down arrow key and
select Page-New.For more information, see Page-New method.
- In the Step page field, press the Down arrow key and select the name of the page to be created by this method.
- On the Pages & Classes tab, enter the name of the page that you reference in step 3b and the class to which the page belongs.
- On the Steps tab of the activity, in the
Method field, press the Down arrow key and
select Page-New.
- Call the service from the activity by using the Connect-REST method.
- On the Steps tab of the activity, click Add a step.
- In the Method field, press the Down arrow key and select Connect-REST.
- In the Method Parameters section, in the ServiceName field, enter the name of the service that you use to retrieve the attachment (the REST connector you configure in step 1), and then click the rule opener.
- In the MethodName field, select GET.
- In the ExecutionMode field, select Run.
- Click Add a step.
- In the Method field, press the Down arrow key and select Java.
- In the Method Parameters section, enter the
following:where ("Name_defined_in_response_clipboard_map_to_key") is the map to key property that you enter in step 1c.
tools.sendFile((byte[])myStepPage.getObject("Name_defined_in_response_clipboard_map_to_key "), "test.xls", false, null, true);
- Click Save.
Previous topic File attachment configuration in REST and SOAP integrations Next topic Use case: Send file attachments from a repository