function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BenabusBenabus 

http post file

Hi all,

 

So my ultimate goal is to take a document that has been uploaded to salesforce and programatically send that file via a post request to an external server to do some parsing on it.

 

Sending regular posts is relatively simple.  Is it possible to do this with a file?  I'm relatively new to apex.

 

Thanks.

Jeff MayJeff May

You would have to package the callout payload in such a way that the receiving web service would accept it.  There are apex Blob methods that will take an Attachment record data and convert it in various ways.

sfdcfoxsfdcfox
Sending binary files are tricky, because salesforce.com doesn't directly support sending files this way.

Instead, use EncodingUtil to convert the file from a blob to base64, then set the HTTP header 'Transfer-Encoding' to 'base64'. Your server needs to support this parameter for this to work, however.