How to handle attachments through REST API


We need to receive attachments through REST API and save it as an attachment in pega. Could anyone please help how to handle attachments through REST API. asap

***Edited by Moderator Marissa to move from Pega Academy to Pega Support Community; update platform capability tags***


Keep up to date on this post and subscribe to comments

October 8, 2019 - 6:14am

Configure it to send and receive multi-part attachments using the pages pyRequestAttachmentPage and pyResponseAttachmentPage.


October 10, 2019 - 8:46am

In the Rest request we will get File Name and File Data as input.

File Name will be like "example.png"
File Data will be an encrypted format of data.

We have to link these data to a work object using "Link-Object" activity method.


October 18, 2019 - 10:24am


I need a assistance on the above. Please can anyone provide the steps to acheive that. I just have info about those two pages only pyRequestAttachmentPage and pyResponseAttachmentPage for Data-ServiceMessage class. 

It would be a great help if any one provide steps.

Thanks in advance

October 18, 2019 - 2:02pm
Response to NareshKumarG

For Pega hosted services (REST or SOAP), the incoming attachments' info is stored in pyRequestAttachmentPage. There are three value list properties under this page.

pyAttachValues - contains the attachment content in base64 encoded form

pyAttachNames - contains the attachment name

pyAttachTypes - contains the mime type of the attachment

If you are receiving multiple attachments in one request, you will have to iterate through each of these value list properties to extract each attachment related info and then create a new page of Data-WorkAttach-File class and copy content from pyAttachValues into pyAttachStream and value from pyAttachNames into pxAttachName, Obj-Save the page and use Link-Objects to create Link-Attachment entry linking the data-workattach-file entry to the work object. You do all this in the REST service activity.