How to convert a System.FileDocument to binary?

0
Hi Everyone,   I am trying to send a System.FileDocument to an external API via REST call through POST request. The request body should be Form-data as the API accepts only form-data request(see screenshot). So the request should be sent in string<binary> format. How should I achieve this using a Javaaction for this conversion?   Thanks in advance!
asked
2 answers
2

Hi Chandana,

 

Most APIs use Base64 as the encoding/decoding (check the documentation). 

https://docs.mendix.com/appstore/modules/community-commons-function-library/#39-stringutils 

 

The JA Base64Encode will transform your binary (as input) to an encoded String, to be used in your form.

 

If still stuck, leave the API description in the comment, so I can guide you more.

 

Go Make It.

answered
1

System.FileDocument is already a BLOB which means its already a Binary.

 

I would suggest to create a Java action to call this webserivce and implement below logic to submit both form and file.

 

https://www.baeldung.com/httpclient-multipart-upload 

 

If it is only file, use

 

answered