Skip to main content


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

Configuring a REST connector to receive binary attachments

Updated on April 6, 2022

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.

Before you begin:
  1. Configure your REST connector to map the response to the clipboard.
    1. On the Methods tab of your REST connector, in the GET section, click the Response tab.
    2. In the Message data section, in the Map to field, select Clipboard.
    3. In the Map to key field, enter the map to key property and then click the rule opener.
      For example: .binaryxls
      Result: The Property Record Configuration page is displayed.
  2. Configure the java object property type and the map to key.
    1. 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.
    2. Click Create and open.
    3. On the General tab, in the Property type section, click ChangeJava Object.
    4. Click Save.
    5. Click Save on the Connect REST rule form.
  3. In the activity, define the page on which the response is mapped.
    1. 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.
    2. In the Step page field, press the Down arrow key and select the name of the page to be created by this method.
      For example: BinaryAttachment
    3. 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.
  4. Call the service from the activity by using the Connect-REST method.
    1. On the Steps tab of the activity, click Add a step.
    2. In the Method field, press the Down arrow key and select Connect-REST.
    3. 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.
    4. In the MethodName field, select GET.
    5. In the ExecutionMode field, select Run.
    6. Click Add a step.
    7. In the Method field, press the Down arrow key and select Java.
    8. In the Method Parameters section, enter the following:
      tools.sendFile((byte[])myStepPage.getObject("Name_defined_in_response_clipboard_map_to_key "), "test.xls", false, null, true);
      where ("Name_defined_in_response_clipboard_map_to_key") is the map to key property that you enter in step 1c.
    9. Click Save.
  • Previous topic File attachment configuration in REST and SOAP integrations
  • Next topic Use case: Send file attachments from a repository

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