multipart/form-data in Connect-REST without base64

Hi All,

Whenever we attach any file in Pega, we need to perform a virus scan (to extend the call virus check functionality) using the existing API on the business side.

API will scan the file and based on the response we need to attach the file.

We have challenges sending a file as “multipart/form-data” in connection-REST.

Our external system does not accept Base64 format. So we should not send base64 format.

How to achieve this?

Regards,

AK

@AK___

So what kind format accepted by the external system. I think you can use java to convert base64 format to accepted format and set value to RequestAttachmentPage. Try it out

@AK___

Pega has an undocumented feature on how to send multipart/form-data across a REST connection. It’s fairly simple, but you just need to know what values to set.

Below is a screenshot of a configuration of a multipart/form-data message that contains json instead of base64 data.

The values you set translate into different values for the multipart message.

Property Multipart property Example
pyAttachValues The actual content you’d like to send { “json”: “data” }
pyAttachNames name “data”
pyAttachTypes content-type “application/json”
pyAttachFileNames filename “payload.json”

When all set, the multipart message would like like below;

----WebKitFormBoundary7MA4YWxkTrZu0gW

Content-Disposition: form-data; name=“data”; filename=“payload.json”
Content-Type: application/json

{ “json”: “data” }
----WebKitFormBoundary7MA4YWxkTrZu0gW

Empty values are possible and leave that particular field out of the message. i.e. an empty pyAttachFieldNames value won’t send a filename.

Note that these properties are value lists and the example above is just for one multipart message. In case you need to send 2 parts, add another items to each list.

@BasM7674 thanks for helping on this forum discussion!

I was wondering whether you can see any areas in our documentation where you think there is room for improvement.

Can you confirm if the functionality should be covered in the following documentation?

File attachment configuration in REST and SOAP integrations

Feel free to give us any feedback of what we could include to help users with this question in the future.

@MarijeSchillern I think that would be a good place to put it. I see half my explanation is already there, just the part how to send a multipart without an attachment is missing if you’d ask me.